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...
23 minutes ago, Frederick said:

I have two TUniEdits on a frame. Using the above JS code, how do I get the ENTER key to work as a Tab from control to control?

Hello,

 

23 minutes ago, Frederick said:

Using the above JS code

Which one?

Link to comment
Share on other sites

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

I deleted the JS code in the BeforeInit event of the TUniFrame and set the properties of the above but the ENTER or Tab still does not move focus from one TUniEdit control to the next.

Remember, the two TUniEdit controls are on a TUniFrame and not in the TUniForm.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...