Page 1 of 1

Key Pressed Custom Action/Event?

PostPosted: Sat Apr 02, 2022 1:42 am
by john1598360627
I want to setup a bit of a sequence of actions.

I want to attach an action event to a key pressed on the keyboard. Which after pressing the key, a window showing a form appears.

In my case, this is for debugging QA purposes.

Here are the two examples;

1. I want to press F11 and bring up a popup window that has various debug tools on it. This is for developer use.

This is referred to as a 'debug menu'.

https://en.wikipedia.org/wiki/Debug_menu

2. Pressing F12 will bring up a Report form in a window. This is for users to report bugs that happen to them.

Again, this would be great for QA.


Any way I can do this?

Re: Key Pressed Custom Action/Event?

PostPosted: Mon Apr 04, 2022 4:44 pm
by sean
HI John,

I don't fully understand your use case, but you can register a keyboard shortcut using the window plugin.
https://wiki.servoy.com/display/DOCS/wi ... methodName)

// i.e on form show first show
plugins.window.createShortcut('f11', myMethod);

Note: Keep in mind that you are competing with the browser's own shortcuts (i.e. f11 in chrome on windos is full screen mode). So pick something unique.

Best,
Sean

Re: Key Pressed Custom Action/Event?

PostPosted: Mon Apr 04, 2022 10:57 pm
by john1598360627
sean wrote:HI John,

I don't fully understand your use case, but you can register a keyboard shortcut using the window plugin.
https://wiki.servoy.com/display/DOCS/wi ... methodName)

// i.e on form show first show
plugins.window.createShortcut('f11', myMethod);

Note: Keep in mind that you are competing with the browser's own shortcuts (i.e. f11 in chrome on windos is full screen mode). So pick something unique.

Best,
Sean

Do button combos work? Like can I setup Ctrl + F1? Would that be,


plugins.window.createShortcut( 'ctrl' + 'f1', myMethod);

EDIT:

Ah, I see from that page you have put the full name.

So it would be 'control F1' ?

Re: Key Pressed Custom Action/Event?

PostPosted: Tue Apr 05, 2022 9:13 am
by Ruben79
The plugins.window.createShortcut has a parameter consumeEvent, if you set that to true, you can consume/override the default browser action:
Code: Select all
plugins.window.createShortcut('F11', myMethod, null, [event], true)

Re: Key Pressed Custom Action/Event?

PostPosted: Wed Apr 06, 2022 12:45 am
by john1598360627
Ruben79 wrote:The plugins.window.createShortcut has a parameter consumeEvent, if you set that to true, you can consume/override the default browser action:
Code: Select all
plugins.window.createShortcut('F11', myMethod, null, [event], true)

I see! I'll consider this.


Also, I noticed my problem was having the method, I was putting the method as 'method()', but as shown it's ONLY the method's name. Ooops!