Page 1 of 1
Detecting keyboard modifier status for Tool (Button) script
Posted: Tue Apr 01, 2014 2:54 am
by SimplSam
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
Re: Detecting keyboard modifier status for Tool (Button) scr
Posted: Tue Apr 01, 2014 4:55 am
by synthsin75
No, button scripts have no way to access keyevents.
Re: Detecting keyboard modifier status for Tool (Button) scr
Posted: Wed Apr 02, 2014 2:55 am
by Breinmeester
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
Posted: Wed Apr 02, 2014 9:52 am
by SimplSam
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!
Re: Detecting keyboard modifier status for Tool (Button) scr
Posted: Wed Apr 02, 2014 4:10 pm
by synthsin75
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.
Re: Detecting keyboard modifier status for Tool (Button) scr
Posted: Wed Apr 02, 2014 6:43 pm
by SimplSam
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.
Hmmm not a bad approach. I am beginning to like that idea.
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
Re: Detecting keyboard modifier status for Tool (Button) scr
Posted: Wed Apr 02, 2014 7:34 pm
by synthsin75
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.