Posted 08 October 2017 - 05:07 PM
maybe i'm too much used to lazarus or delphi and now have problem:
have choosen visual component, add label1 and directly onkeydown of form1 wrote label1.caption:='Hello', expecting that after pressing whatever on keyboard i'll see on text Hello. instead of that, nothing happens.
if I first press a <tab> button and then some key then it works. When i press and hold pressed <tab> works as well. Seems that something else is first focused? Could someone explain me that?
Posted 08 October 2017 - 07:09 PM
procedure TForm1.KeyDownEvent(mCode: integer);
case mCode of
66 : labb.caption:='Hello';
// this is a good place to initialize components
window.onkeydown = function(e)
But not sure if there is some more elegant solution?
Posted 08 October 2017 - 10:39 PM
To clarify; you have used the OnKeyDown (TKeyDownEvent) but it doesn't work as intended for you?
If you are trying to use the Form's OnKeyDown even you may have to call .SetFocus; in InitializeForm.
Posted 09 October 2017 - 10:38 PM
Are you using new alpha? If so, perhaps you need to flag that you intend to listen for keys, I know it's mandatory for custom controls to add cfKeyCapture to CreationFlags, but I'm not sure about added forms and controls on it, check.
Alternative is of course to just use MYForm.Handle.addEventListener and make a classic JS event.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users