Frederick Posted June 23, 2025 Posted June 23, 2025 I am trying to trap the ALT+E key combination in the form's OnKeyDown event to set focus to an edit control. procedure TUniForm.UniFormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if ssAlt in Shift then begin if Key=69 then TUniEdit.SetFocus; end; end; However, the browser's menu is brought up first before focus changes to the edit control. How do I suppress the browser's menu from being shown? -- Frederick (UniGUI Complete - Professional Edition 1.95.0.1577) Quote
Sherzod Posted June 24, 2025 Posted June 24, 2025 6 hours ago, Frederick said: However, the browser's menu is brought up first before focus changes to the edit control. Hello, You can analyze the demo "\FMSoft\Framework\uniGUI\Demos\Desktop\MonitoredKeys" 1. 2. 3. procedure TMainForm.UniFormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin case Key of 69: // 'e' if ssCtrl in Shift then ShowMessage('Ctrl+E pressed') end; end; Quote
Frederick Posted June 24, 2025 Author Posted June 24, 2025 Thanks for the reference and code. It works and the menu for the browser does not appear. However, after pressing the key combination to set focus to the TUniEdit, I am unable to enter any letters into the TUniEdit. It appears that the MonitoredKeys property is ignoring key strokes that do not have the Alt key prefix. My OnKeyDown event is below:- procedure TUniForm.UniFormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin case Key of 69 : begin if ssAlt in Shift then begin if Key=VK_E then // VK_E defined as 69 TUniEdit.SetFocus; end; end; end; end; How do I fix this issue? Quote
Sherzod Posted June 24, 2025 Posted June 24, 2025 2 hours ago, Frederick said: However, after pressing the key combination to set focus to the TUniEdit, I am unable to enter any letters into the TUniEdit. It appears that the MonitoredKeys property is ignoring key strokes that do not have the Alt key prefix. This is not entirely correct — it seems something might be misconfigured or incorrectly handled on your side. Quote
Frederick Posted June 24, 2025 Author Posted June 24, 2025 Here is the testcase based on your demo's MonitoredKeys project. Press the ALT+E key combination and the focus will go to the TUniEdit. Try typing any letter from A to Z and you will see that nothing appears. monitorkeys.zip Quote
Sherzod Posted June 24, 2025 Posted June 24, 2025 1 hour ago, Frederick said: Here is the testcase based on your demo's MonitoredKeys project. Press the ALT+E key combination and the focus will go to the TUniEdit. Try typing any letter from A to Z and you will see that nothing appears. https://www.unigui.com/doc/online_help/api/uniGUIForm_TUniForm_KeyPreview.html Quote
Frederick Posted June 24, 2025 Author Posted June 24, 2025 When the KeyPreview is set to False and the form is focused, pressing ALT+E will set focus to the TUniEdit and characters can be typed in. However, when I press ALT+<any other letter> from the TUniEdit control, the code in the OnKeyDown event is ignored and I cannot update the memo box. Quote
Sherzod Posted June 24, 2025 Posted June 24, 2025 1 hour ago, Frederick said: However, when I press ALT+<any other letter> from the TUniEdit control, the code in the OnKeyDown event is ignored and I cannot update the memo box. Make a simple testcase if possible. Quote
Frederick Posted June 24, 2025 Author Posted June 24, 2025 Please find the modified testcase attached. Steps to reproduce:- 1. Press ALT+E (Focus goes to the TUniEdit and the memo box shows "E") 2. Press ALT+A to click the Add button (Nothing happens) monitorkeys2.zip Quote
Frederick Posted June 27, 2025 Author Posted June 27, 2025 After spending several hours, I was able to use the ALT+<key> combination from within the TUniEdit by setting the TUniEdit's OnKeyDown event to the form's OnKeyDown event. However, the main problem is that the MonitoredKeys property works at the form level only. If the ALT+<key> combination is pressed at the control and the former matches a browser's menu shortcut, the browser's menu will pop up. This renders the MonitoredKeys property unusable if the ALT key has to be pressed at a TUniEdit or other control. To see the result in the attached testcase, do the following:- 1. Press ALT+E (The email edit box is focused. Browser's menu not displayed.) 2, Press ALT+T (The name edit box is focused. Browser's menu not displayed because there is no menu shortcut for T.) 3. Press ALT+E (The email edit box is focused but the browser's menu is now displayed.) monitorkeys3.zip 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.