* * *

Author Topic: TFileNameEdit Execute Dialog through OnKeyDown  (Read 167 times)

M+AUDIO

  • New member
  • *
  • Posts: 37
TFileNameEdit Execute Dialog through OnKeyDown
« on: October 12, 2017, 06:00:00 pm »
Hi,
didn't wanted to bump this old thread.
since the button part does not gets the focus, handling it in TFileNameEdit.OnKeyDown is the only way I have, I think.
now my question is why such a hack? why TFileNameEdit.RunDialog is not public? what are those risks?

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3122
  • I like bugs.
Re: TFileNameEdit Execute Dialog through OnKeyDown
« Reply #1 on: October 12, 2017, 06:14:38 pm »
What exactly do you want to achieve?
There is also a separate TOpenDialog. No need to hack TFileNameEdit.

M+AUDIO

  • New member
  • *
  • Posts: 37
Re: TFileNameEdit Execute Dialog through OnKeyDown
« Reply #2 on: October 12, 2017, 06:41:57 pm »
so you suggest me to put a TOpenDialog + a TEdit + a TButton to do the job (opening a single file as input file)? instead of a single TFileNameEdit?
I think TFileNameEdit is just fine.  I wanted to give the user also ability to work with his keyboard if he wants. hence the first post.

M+AUDIO

  • New member
  • *
  • Posts: 37
Re: TFileNameEdit Execute Dialog through OnKeyDown
« Reply #3 on: October 12, 2017, 07:17:31 pm »
P. S.
It is not a big deal.
I'm doing it this way:

Code: Pascal  [Select]
  1. interface
  2.  
  3. uses
  4.   ...EditBtn...
  5.  
  6. type
  7.   { TForm1 }
  8.   TForm1 = class(TForm)
  9.   ...
  10.   procedure MyFileNameEditKeyDown(Sender: TObject; var Key: Word;
  11.   Shift: TShiftState);
  12.   ...
  13.   end;
  14.  
  15.   { TFileNameEditHelper }
  16.   TFileNameEditHelper = class helper for TFileNameEdit
  17.   public
  18.     procedure ShowDialog;
  19.   end;
  20.  
  21. implementation
  22. ...
  23. { TForm1 }
  24. procedure TForm1.MyFileNameEditKeyDown(Sender: TObject; var Key: Word;
  25.   Shift: TShiftState);
  26. begin
  27.   if (Key = VK_RETURN) and (Shift = [ssCtrl]) then
  28.     (Sender as TFileNameEdit).ShowDialog;
  29. end;
  30. ...
  31. { TFileNameEditHelper }
  32. procedure TFileNameEditHelper.ShowDialog;
  33. begin
  34.   RunDialog;
  35. end;
  36. ....
  37.  

But you saying it is not going to be public for some reasons? OK that's it.
Edit: class helper
« Last Edit: October 16, 2017, 03:57:45 pm by M+AUDIO »

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus