Recent

Author Topic: List Box in Lazarus: Keyboard shortcut for double-click?  (Read 1075 times)

AMJF

  • New Member
  • *
  • Posts: 48
List Box in Lazarus: Keyboard shortcut for double-click?
« on: May 04, 2021, 11:06:54 pm »
I'm using Windows 10, but different apps require different keyboard shortcuts for double-clicking (like a mouse does), so I'm wondering what Lazarus/FPC apps use?

AMJF

  • New Member
  • *
  • Posts: 48
Re: List Box in Lazarus: Keyboard shortcut for double-click?
« Reply #1 on: May 05, 2021, 12:38:07 am »
To elaborate, in my program with a TListBox, I find that using the up/down arrow keys is apparently the same as clicking on each item in the list box with the mouse, but sequentially. So I'm wondering if I can program in an option to double-click with the keyboard in the list box with, say, the Enter key?

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: List Box in Lazarus: Keyboard shortcut for double-click?
« Reply #2 on: May 05, 2021, 01:18:06 am »
Code: Pascal  [Select][+][-]
  1.  
  2. procedure TForm1.ListBox1DblClick(Sender: TObject);
  3. begin
  4.   beep;
  5. end;
  6.  
  7. procedure TForm1.ListBox1KeyPress(Sender: TObject; var Key: char);
  8. begin
  9.   if Key = #13 then ListBox1DblClick(Sender);
  10. end;                                      
  11.  
  12.  

The only true wisdom is knowing you know nothing

AMJF

  • New Member
  • *
  • Posts: 48
Re: List Box in Lazarus: Keyboard shortcut for double-click?
« Reply #3 on: May 05, 2021, 03:32:00 am »
The second procedure works fine, but do I need the "beep"? Seems to work without it.

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: List Box in Lazarus: Keyboard shortcut for double-click?
« Reply #4 on: May 05, 2021, 03:46:32 am »
That's my brand! >:(

Do as you please with the beep!, its just there as a test!

The only true wisdom is knowing you know nothing

AMJF

  • New Member
  • *
  • Posts: 48
Re: List Box in Lazarus: Keyboard shortcut for double-click?
« Reply #5 on: May 05, 2021, 04:50:21 am »
Don't be offended, the tip is much appreciated.

If the beep is for feedback, then in my case, I will know if it works, and it does.

Thanks!

 

TinyPortal © 2005-2018