Jump to content

Using Ctrl + S for my own app (bypassing browser)


Jean-Marc Kiener
 Share

Recommended Posts

Hi experts,

 

I try to build a form who let the user edit data from a database. I figured it out ( thanks to this forum :-) ) how to configure F1..F8 Keys so i can handle it exclusively in my app (the browser ignores them). The form property monitoredkeys stuff does the job. Great!

Now i want do this with Ctrl+S, Ctrl+D, Ctrl+E etc. 

 

Is this possible?

Link to comment
Share on other sites

Hi,

 

For now try this:

 

1. MainForm->ClientEvents->UniEvents: window.afterCreate fn:

function window.afterCreate(sender) 
{
    Ext.onReady(function() {
        document.onkeydown = function(e) {
            e = e || window.event;
            if (e.ctrlKey) {
                var c = e.which || e.keyCode;
                switch (c) {
                    case 68: // D
                    case 69: // E
                    case 83: // S
                        ajaxRequest(sender.uform, "ctrlkey", ["keycode=" + c]);
                        e.preventDefault();
                        e.stopPropagation();
                        break;                    
                }
            }
        };
    })
}

2. MainForm->onAjaxEvent:

procedure TMainForm.UniFormAjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = 'ctrlkey' then
  begin
    if Params.Values['keycode'] = '83' then
    begin
      ShowMessage('Ctrl+S');
    end;
  end;
end;

Best regards

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.

 Share

×
×
  • Create New...