Skip to content

Commit 76889be

Browse files
committed
Assign focus to Edit when component receives focus
1 parent 8920943 commit 76889be

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/TagEdit.pas

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ TCustomTagEdit = class(TCustomControl)
245245
public
246246
constructor Create(AOwner: TComponent); override;
247247
destructor Destroy; override;
248+
procedure SetFocus; override;
248249
procedure AddTag(const ATag: string; AEditing: boolean = False);
249250
function RemoveTag(const ATag: string; AConfirm: boolean = False): boolean;
250251
function Focused: boolean; override;
@@ -500,6 +501,12 @@ destructor TCustomTagEdit.Destroy;
500501
inherited Destroy;
501502
end;
502503

504+
procedure TCustomTagEdit.SetFocus;
505+
begin
506+
inherited;
507+
SetFocusOnEdit;
508+
end;
509+
503510
function TCustomTagEdit.GetTags: TStringList;
504511
begin
505512
Result := FTags;
@@ -687,7 +694,8 @@ procedure TCustomTagEdit.SetSuggestedButtonGlyph(AValue: TBitmap);
687694

688695
procedure TCustomTagEdit.SetFocusOnEdit;
689696
begin
690-
if Self.Visible and FEdit.Visible and FEdit.CanFocus then FEdit.SetFocus;
697+
if Visible and FEdit.Visible and FEdit.CanFocus then
698+
FEdit.SetFocus;
691699
end;
692700

693701
procedure TCustomTagEdit.UpdateEditPosition;
@@ -1423,9 +1431,11 @@ procedure TCustomTagEdit.CheckListItemChecked(Sender: TObject; Index: integer; C
14231431
RemoveTag(FCheckListButton.Items[Index]);
14241432

14251433
try
1426-
Application.ProcessMessages;
14271434
if FUpdatePopup and FCheckListButton.PopupVisible then
1435+
begin
1436+
Application.ProcessMessages;
14281437
FCheckListButton.UpdatePopupForm;
1438+
end;
14291439
finally
14301440
FUpdatePopup := False;
14311441
end;
@@ -1450,9 +1460,11 @@ procedure TCustomTagEdit.CheckListAfterBulkChange(Sender: TObject);
14501460
if Length(FCheckListRemoved) > 0 then
14511461
RemoveTag(FCheckListRemoved);
14521462

1453-
Application.ProcessMessages;
14541463
if FUpdatePopup and FCheckListButton.PopupVisible then
1464+
begin
1465+
Application.ProcessMessages;
14551466
FCheckListButton.UpdatePopupForm;
1467+
end;
14561468
finally
14571469
FUpdatePopup := False;
14581470
FCheckListInBulk := False;

0 commit comments

Comments
 (0)