Jump to content

TUniFrame, OnKeyDown Event


belo

Recommended Posts

Hi,

In the attachment, an example of how to use the OnKeyDown event with the KeyMap object of the Ext.panel.Panel in TUniFrame.

function beforeInit(sender, config)
{
   config.keyMap = {
        a: {
            handler: function() {
                Ext.Msg.alert('key pressed', 'you have pressed a');
            }
        },
        F2: {
            handler: function() {
              ajaxRequest(sender, '_F2', []);
            }
        },
        ESC: {
            handler: function() {
              ajaxRequest(sender, '_ESC', []);
            }
        },
        DELETE: {
            handler: function() {
              ajaxRequest(sender, '_DELETE', []);
            }
        }                
    }     
}

Demo

Regards,

Eduardo Belo

 

 

UniGUIFramesKeyEvents.rar

  • Like 3
  • Upvote 1
Link to comment
Share on other sites

  • 4 weeks later...

 

Hi Flávio!

I didn't quite understand your question, but maybe it will help you..

// UniEdit
function beforeInit(sender, config)
{
   config.keyMap = {
        SPACE: { // keyCode = 32
            handler: function() {
              ajaxRequest(sender, '_SPACE', []);
            }
        }                
    } 
}
procedure TMainForm.UniEdit1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = '_SPACE' then
  begin
   InsertFrame(TUniFrame(TUniFrame1), 'Frame 1', True);
  end;
end;

Best regards,

Eduardo Belo

Link to comment
Share on other sites

  • 10 months later...
4 hours ago, Sherzod said:

\FMSoft\Framework\uniGUI\Demos\Desktop\MonitoredKeys

?

It really works well there, but if you take the AllFeatures Demo

Frame

UniFormControlsComboBox

Place the code

procedure TUniFormControlsComboBox.UniComboBox3KeyDown (Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  case Key of
    VK_F1 .. VK_F12:
      ShowMessage ('test');
  end;
end;

pressing F3 will give the message, but it will call the browser's search.

Link to comment
Share on other sites

5 hours ago, picyka said:

It really works well there, but if you take the AllFeatures Demo

pressing F3 will give the message, but it will call the browser's search.

Well, yes, you should analyze the demo example!
There are other settings.

1. MainForm.KeyPreview = True

2. MainForm.MonitoredKeys.Enabled=True,

    MainForm.MonitoredKeys.KeyEnableAll=False,

    MainForm.MonitoredKeys.KeyHandleAll=False

3. MainForm.MonitoredKeys.Keys[0]

        HandleBrowser=False

        KeyEnd=123

        KeyStart=112 

Link to comment
Share on other sites

5 hours ago, Sherzod said:

Well, yes, you should analyze the demo example!
There are other settings. 

1. MainForm.KeyPreview = True

2. MainForm.MonitoredKeys.Enabled=True,

    MainForm.MonitoredKeys.KeyEnableAll=False,

    MainForm.MonitoredKeys.KeyHandleAll=False

3. MainForm.MonitoredKeys.Keys[0]

        HandleBrowser=False

        KeyEnd=123

        KeyStart=112 

I will test soon, thanks!

Link to comment
Share on other sites

  • 2 years later...

This one.

function beforeInit(sender, config)
{
   config.keyMap = {
        a: {
            handler: function() {
                Ext.Msg.alert('key pressed', 'you have pressed a');
            }
        },
        F2: {
            handler: function() {
              ajaxRequest(sender, '_F2', []);
            }
        },
        ESC: {
            handler: function() {
              ajaxRequest(sender, '_ESC', []);
            }
        },
        DELETE: {
            handler: function() {
              ajaxRequest(sender, '_DELETE', []);
            }
        }                
    }     
}
Link to comment
Share on other sites

8 minutes ago, Frederick said:

I added the above code in my test project and I cannot seem to tab or press the ENTER key to move from one TUniEdit to another.

Yes, this code does not do what you want. You asked how we can capture Enter, and I answered.

And without this code, you can achieve what you want:

UniMainModule ->

image.png.c289d780ea1e30093491070f33ace4b5.png

Link to comment
Share on other sites

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