Not getting TAB key in OnKeyDown

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Not getting TAB key in OnKeyDown

Postby smd » Tue Jan 12, 2016 6:16 pm

Firemonkey RAD 10

I have a simple form in which I am manipulating some images. I created an OnKeyDown event to capture key board inputs to do various actions. All keys are captured except TAB. In my previous programs, using either the TMemo component or the TMSMemo from TMS Software, if I pressed the TAB key, the key code passed to the OnKeyDown event.

My new form is not using any of the text editing components. I have an OnKeyDown event for the form which works for all keys except the TAB key. I dug through the documentation but could not find how to get the TAB key to pass to the OnKeyDown event. On a documentation page about KeyDown, it stated that the TAB key is singled out to be used for switching processes or forms.

How, or what do I override/set/clear so that for a Firemonkey form the tab key is passed to the OnKeyDown event instead of being intercepted?
-----------------------------
Scott
smd
BCBJ Guru
BCBJ Guru
 
Posts: 130
Joined: Sat Nov 29, 2014 8:02 pm
Location: Las Vegas

Re: Not getting TAB key in OnKeyDown

Postby smd » Tue Jan 12, 2016 7:50 pm

I figured it out.

I never used virtual functions before, mostly due to I code in C most of the time for embedded controllers. KeyDown is a virtual function which can be overridden by my own function. I copied from the help page for KeyDown its prototype, pasted it into the header file for the form class. Now all key presses pass through this function, which also means I have to process everything, not just my special keys.

Code: Select all
void __fastcall TMyForm::KeyDown(System::Word &Key,  System::WideChar &KeyChar,         System::Classes::TShiftState Shift)
  {
.
.
.
  }
-----------------------------
Scott
smd
BCBJ Guru
BCBJ Guru
 
Posts: 130
Joined: Sat Nov 29, 2014 8:02 pm
Location: Las Vegas


Return to Technical

Who is online

Users browsing this forum: Google [Bot] and 6 guests

cron