Recent

Author Topic: TDirectoryEdit - Open Dialog with Keyboard  (Read 1795 times)

OLLI_S

  • Full Member
  • ***
  • Posts: 119
TDirectoryEdit - Open Dialog with Keyboard
« on: March 09, 2019, 11:42:44 pm »
Hello,

I am using Lazarus 2.0.0 in Windows 10 Professional x64.

On my form I have a TDirectoryEdit control and it is working fine.
The only problem is that the button after the edit-field can not be focused with the keyboard (with the <Tab> key) and that no other keyboard shortcuts are working.

So is there a way to focus the button behind the edit field with the tab key?

Best regards

OLLI

ASerge

  • Hero Member
  • *****
  • Posts: 2242
Re: TDirectoryEdit - Open Dialog with Keyboard
« Reply #1 on: March 10, 2019, 04:09:58 am »
The only problem is that the button after the edit-field can not be focused with the keyboard (with the <Tab> key) and that no other keyboard shortcuts are working.
So is there a way to focus the button behind the edit field with the tab key?
I doubt it, considering it's is the TSpeedButton. It may be easier to assign hotkeys?
Code: Pascal  [Select][+][-]
  1. uses LCLType;
  2.  
  3. type
  4.   TDirectoryEditHelper = class helper for TDirectoryEdit
  5.     procedure DoButtonClick; inline;
  6.   end;
  7.  
  8. procedure TDirectoryEditHelper.DoButtonClick;
  9. begin
  10.   ButtonClick;
  11. end;
  12.  
  13. procedure TForm1.DirectoryEdit1KeyDown(Sender: TObject; var Key: Word;
  14.   Shift: TShiftState);
  15. begin
  16.   // Same as internal hot keys for the TComboBox
  17.   if ((Key = VK_F4) and (Shift = [])) or ((Key = VK_DOWN) and (Shift = [ssAlt])) then
  18.     (Sender as TDirectoryEdit).DoButtonClick;
  19. end;

 

TinyPortal © 2005-2018