Jump to content

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


Jean-Marc Kiener

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...