Jump to content

Recommended Posts

Posted

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)
 

Posted
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. image.png.1e212b7c0b84d3d7a9e3f3feedb7d5f3.png

2. image.png.28a4d2ba3370e822517e207e7db9a789.png

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;

 

Posted

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?

Posted
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.

Posted

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.

Posted
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.

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...