Key Pressed Custom Action/Event?

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Key Pressed Custom Action/Event?

Postby john1598360627 » Sat Apr 02, 2022 1:42 am

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?
john1598360627
 
Posts: 169
Joined: Tue Aug 25, 2020 3:03 pm

Re: Key Pressed Custom Action/Event?

Postby sean » Mon Apr 04, 2022 4:44 pm

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
Software Engineer
Servoy USA
sean
 
Posts: 370
Joined: Mon May 21, 2007 6:26 pm
Location: USA

Re: Key Pressed Custom Action/Event?

Postby john1598360627 » Mon Apr 04, 2022 10:57 pm

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' ?
john1598360627
 
Posts: 169
Joined: Tue Aug 25, 2020 3:03 pm

Re: Key Pressed Custom Action/Event?

Postby Ruben79 » Tue Apr 05, 2022 9:13 am

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)
Ruben de Jong
Stb Software Development
SAN Partner

Stb Software Development - http://www.stb.nl
User avatar
Ruben79
 
Posts: 97
Joined: Wed Apr 18, 2007 12:43 pm

Re: Key Pressed Custom Action/Event?

Postby john1598360627 » Wed Apr 06, 2022 12:45 am

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!
john1598360627
 
Posts: 169
Joined: Tue Aug 25, 2020 3:03 pm


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 7 guests