Recent

Author Topic: TToolBar capturing OnKeyDown events?  (Read 4086 times)

VTwin

  • Hero Member
  • *****
  • Posts: 1227
  • Former Turbo Pascal 3 user
TToolBar capturing OnKeyDown events?
« on: January 29, 2011, 08:22:21 pm »
I'm wondering if this is a bug, I couldn't find anything describing it. I make a new project and add a TToolBar, and a OnKeyDown event:

Code: [Select]
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  ShowMessage('You pressed key #' + IntToStr(key));
end;

The event is triggered until I click on the (empty) TToolBar, then it is not. It seems TToolBar got the focus and is capturing the event. Clicking back on the Frame does not change it back.

Thanks,
Frederick

OS X 10.6.5 Intel
Lazarus 0.9.31
Carbon Widgets
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 15.3.2: Lazarus 3.8 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 3.8 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 3.8 (64 bit on VBox)

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: TToolBar capturing OnKeyDown events?
« Reply #1 on: January 29, 2011, 08:33:30 pm »
Is property Form1.KeyPreview=True ? Maybe it will help...
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

VTwin

  • Hero Member
  • *****
  • Posts: 1227
  • Former Turbo Pascal 3 user
Re: TToolBar capturing OnKeyDown events?
« Reply #2 on: January 29, 2011, 08:42:03 pm »
That did the trick! Many thanks Blaazen.
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 15.3.2: Lazarus 3.8 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 3.8 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 3.8 (64 bit on VBox)

 

TinyPortal © 2005-2018