Hi,
I have created a Tool (Button) script, and I would like to determine if the Control (CTRL) key was depressed at the time when the script was invoked (or during the scripts execution).
Essentially it would extend the usefulness / functionality of the Tools (Button) feature, allowing the script to execute normally for a normal button click, and execute with different behavior if certain modifier keys were used.
I understand that the normal mechanism to detect user interaction would be to use Event Driven processing (keyEvent, mouseEvent) to determine modifier key status, but the Tool (Button) invocation does not appear to register as a handler for those events.
I was hoping that there was some Global register that I could peek at to get the modifier keys status.
Thanks
Detecting keyboard modifier status for Tool (Button) script
Moderators: Víctor Paredes, Belgarath, slowtiger
Detecting keyboard modifier status for Tool (Button) script
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam
Sam
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam
Sam
- synthsin75
- Posts: 9972
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Detecting keyboard modifier status for Tool (Button) scr
No, button scripts have no way to access keyevents.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
-
- Posts: 303
- Joined: Thu May 13, 2010 2:01 pm
Re: Detecting keyboard modifier status for Tool (Button) scr
The Edit Keyboard Shortcuts dialog allows you to set modifier keys for tools. In your case you would have to have different tools for different key combinations, but that would take up too much space in the Tool window. If we could also set shortcuts for the Scripts menu, it wouldn't be a problem.
Re: Detecting keyboard modifier status for Tool (Button) scr
Yeah - I was trying to keep it simple. Not go adding multiple buttons or additional keyboard shortcuts.
The real idea was to have the Button function normally to do something quick and simple, but then have the option to pull up a configuration dialog and change the buttons default behavior (preferences) - if the user pressed CTRL and Button (for example).
We can but dream!
The real idea was to have the Button function normally to do something quick and simple, but then have the option to pull up a configuration dialog and change the buttons default behavior (preferences) - if the user pressed CTRL and Button (for example).
We can but dream!
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam
Sam
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam
Sam
- synthsin75
- Posts: 9972
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Detecting keyboard modifier status for Tool (Button) scr
I have one button script that I ended up using frame zero and the selected layer visibility (eyes) disabled to evoke an options menu when pressed. Otherwise it does its usual function.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Re: Detecting keyboard modifier status for Tool (Button) scr
Hmmm not a bad approach. I am beginning to like that idea.synthsin75 wrote:I have one button script that I ended up using frame zero and the selected layer visibility (eyes) disabled to evoke an options menu when pressed.
I was also thinking of a 'dirty flag' file, on the File System (but that's inconvenient), or if the button was invoked on an empty unsaved document.
You have given me food for thought.
Cheers
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam
Sam
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam
Sam
- synthsin75
- Posts: 9972
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Detecting keyboard modifier status for Tool (Button) scr
Yeah, on that particular button script I went a bit crazy with the idea of context sensitivity. If you press it in one circumstance you get an option menu, in others it creates layers, changes selected layer, and various other things. Mostly depending on which layer is selected and what content it has at the time.
Works well, but makes the script too difficult to explain how to use it to others. One of those cases where I wrote a script solely for my liking. I'd probably have to make it a tool or multiple button scripts for others to use.
Works well, but makes the script too difficult to explain how to use it to others. One of those cases where I wrote a script solely for my liking. I'd probably have to make it a tool or multiple button scripts for others to use.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/