tvplanig: Cancel contact inplace-editor with ESC key.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6479 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-06-09 11:21:35 +00:00
parent abf9796c82
commit 5f0337539e
2 changed files with 38 additions and 30 deletions

View File

@ -83,7 +83,7 @@ type
procedure CreateParams(var Params: TCreateParams); override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
public
field: string;
Field: string;
constructor Create(AOwner: TComponent); override;
procedure Move(const Loc: TRect; Redraw: Boolean);
end;
@ -358,7 +358,6 @@ begin
Height := 1;
Width := 1;
end;
{=====}
procedure TVpCGInPlaceEdit.Move(const Loc: TRect; Redraw: Boolean);
var
@ -387,46 +386,54 @@ begin
if Redraw then Invalidate;
SetFocus;
end;
{=====}
procedure TVpCGInPlaceEdit.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.Style := Params.Style{ or ES_MULTILINE};
end;
{=====}
procedure TVpCGInPlaceEdit.KeyDown(var Key: Word; Shift: TShiftState);
var
Grid : TVpContactGrid;
Grid: TVpContactGrid;
begin
Grid := TVpContactGrid(Owner);
case Key of
VK_RETURN: begin
Key := 0;
Grid.EndEdit(Self);
Grid.SetFocus;
end;
VK_RETURN:
begin
Key := 0;
Grid.EndEdit(Self);
Grid.SetFocus;
end;
VK_UP: begin
Grid.EndEdit(Self);
Grid.ContactIndex := Grid.ContactIndex - 1;
Key := 0;
Grid.SetFocus;
end;
VK_UP:
begin
Grid.EndEdit(Self);
Grid.ContactIndex := Grid.ContactIndex - 1;
Key := 0;
Grid.SetFocus;
end;
VK_DOWN: begin
Grid.EndEdit(Self);
Grid.ContactIndex := Grid.ContactIndex + 1;
Key := 0;
Grid.SetFocus;
end;
else
inherited;
VK_DOWN:
begin
Grid.EndEdit(Self);
Grid.ContactIndex := Grid.ContactIndex + 1;
Key := 0;
Grid.SetFocus;
end;
VK_ESCAPE:
begin
Hide;
Key := 0;
Grid.SetFocus;
end;
else
inherited;
end;
end;
{=====}
(*****************************************************************************)
{ TVpContactGrid }
@ -1299,7 +1306,7 @@ begin
{ edit address }
if field = 'Address' then begin
cgInPlaceEditor.Field := field;
cgInPlaceEditor.Field := 'Address1';
cgInPlaceEditor.Move(AddressRect, true);
Canvas.DrawFocusRect(Rect(AddressRect.Left + TextMargin - 1,
AddressRect.Top, AddressRect.Right + 3, AddressRect.Bottom + 3));
@ -1324,7 +1331,7 @@ begin
end;
{ edit email }
if field = 'EMail' then begin
cgInPlaceEditor.Field := field;
cgInPlaceEditor.Field := 'EMail1';
cgInPlaceEditor.Move(EMailRect, true);
Canvas.DrawFocusRect(Rect(EMailRect.Left - TextMargin,
EMailRect.Top, EMailRect.Right + 3, EMailRect.Bottom + 3));
@ -1384,7 +1391,7 @@ procedure TVpContactGrid.EndEdit(Sender: TObject);
var
City, State, Zip: string;
begin
if cgInPlaceEditor <> nil then begin
if Assigned(cgInPlaceEditor) and cgInPlaceEditor.Visible then begin
{Address}
if cgInPlaceEditor.field = 'Address' then begin
if cgInPlaceEditor.Text <> FActiveContact.Address1 then begin

View File

@ -47,6 +47,7 @@ type
implementation
uses
StrUtils,
VpCanvasUtils, VpMisc, VpSR;
type
@ -430,7 +431,7 @@ begin
DrawContactLine(TmpBmp, TmpCon.Company, '', WholeRect, CompanyRect);
{ do address... }
DrawContactLine(TmpBmp, TmpCon.Address, '', WholeRect, AddrRect);
DrawContactLine(TmpBmp, TmpCon.Address1, '', WholeRect, AddrRect);
{ do City, State, Zip }
Str := AssembleCSZ(TmpCon, 1, FContactGrid.GetCityStateZipFormat);
@ -457,7 +458,7 @@ begin
DrawContactLine(TmpBmp, TmpCon.Phone5, Str, WholeRect, Phone5Rect);
{ do EMail }
DrawContactLine(TmpBmp, TmpCon.EMail, RSEmail + ': ', WholeRect, EMailRect);
DrawContactLine(TmpBmp, TmpCon.EMail1, RSEmail + ': ', WholeRect, EMailRect);
{ if this record's too big to fit in the remaining area of this }
{ column, then slide over to the top of the next column }