Mauri Posted October 9, 2016 Posted October 9, 2016 How trigger event on the keyboard? In Delphi I was like this: keybd_event (VK_TAB, 0,0,0); (Method unit WinApi.Windows) How can I have this same behavior in UniGUI, or shoot a keyboard event? Quote
Sherzod Posted October 10, 2016 Posted October 10, 2016 Hi, In the "web programming" the "situation" is different, can you clarify for what purpose you want to use it ?! Best regards. Quote
Mauri Posted October 10, 2016 Author Posted October 10, 2016 In my Delphi application I have a Memo component custom inherited from TCustomMemo class that has an implementation in onKeyPress method so that when the user clicks twice in a row the ENTER key the focus goes to the next component. TIDMemo = class(TCustomMemo) private ... fTabEnter: Boolean; fKeyAnt: Char; protected ... procedure KeyPress(var Key: Char); override; public ... published ... end; procedure TIDMemo.KeyPress(var Key: Char); begin if ((key = #13) and (fKeyAnt = #13) and fTabEnter) or ((key = #13) and (MaxLength > 0) and (length(Lines.Text) > MaxLength - 2) and fTabEnter) then if (Lines.Count > 0) then if (trim(Lines.Strings[Lines.Count - 1]) = '') or (length(Lines.Text) > MaxLength - 2) then begin key:= #0; inherited; if (trim(Lines.Strings[Lines.Count - 1]) = '') then key:= #8; keybd_event(9,0,0,0); // Triggers TAB Key exit; end; fKeyAnt:= Key; inherited; end; Quote
Sherzod Posted October 10, 2016 Posted October 10, 2016 Hi, If I understand correctly you, can you analyze and modify this code?!: ... public { Public declarations } fTabEnter: Boolean; fKeyAnt: Char; end; ... procedure TMainForm.UniMemo1KeyPress(Sender: TObject; var Key: Char); begin fTabEnter := True; if ((key = #13) and (fKeyAnt = #13) and fTabEnter) then begin fKeyAnt := #0; SelectNext(TUniMemo(Sender)); end; fKeyAnt := Key; end; Best regards. Quote
Mauri Posted October 10, 2016 Author Posted October 10, 2016 Thank you so much !!! It worked properly and it was just that I needed Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.