Page 1 of 1

Tool change shortcut

Posted: Mon Jan 15, 2018 3:12 am
by hoanghuynh
After all these years, I just thought of using the right button on my mouse to switch between browse and pointer tools.
CODE: SELECT ALL

on rawKeyUp tKey
if tKey = 65473 then if the tool = "browse tool" then choose "pointer tool" else choose "browse tool"
end rawKeyUp
Put it into a plug-in. What a dope.

Re: Tool change shortcut

Posted: Mon Jan 15, 2018 8:38 am
by richmond62
Um . . . that could cause problems.

How about modifying it a bit:
on rawKeyUp tKey
if tKey = 65473 then
if the tool = "browse tool" then
choose "pointer tool"
else choose "browse tool"
end if
else pass rawKeyUp
end if
end rawKeyUp
I believe that without pass rawKeyUp
you won't get any reactions from any other keys.

It is not a bad idea to layout your code the way I have done
to make it easier for people to work out what is meant to be
going on.

Re: Tool change shortcut

Posted: Mon Jan 15, 2018 10:48 am
by richmond62
On my iMac (10.7.5) when I click on
a stack containing this code with my
right mouse button:

Code: Select all

on rawKeyUp RUP
   put RUP
end rawKeyUp
I get NOTHING.

with this:

Code: Select all

on rawKeyUp RUP
   set the backGroundColor to red
end rawKeyUp
Nothing happens either.

Re: Tool change shortcut

Posted: Mon Jan 15, 2018 10:53 am
by richmond62
HOWEVER:

Code: Select all

on mouseUp TRI
   if TRI = 3 then
      put "gottit"
      end if
end mouseUp
works perfectly.

Re: Tool change shortcut

Posted: Mon Jan 15, 2018 4:47 pm
by bn
Hi hoanghuynh,

welcome to the forum.

there are a couple of issues with your approach.

rawkey 65473 is F-Key 4, so a mouse operation would never trigger this. Almost all rawkey-related messages are keyboard triggered, the scroll wheel also sends rawKey messages.
A mouse operation would send a couple of mouse-related messages. mouseDown, mouseUp, mouseStilldown, mouseDoubleUp etc with one parameter that indicates right, left or middle (1,2,3)

You want to put this into a plugin. Please consider the message path when you plan your stack.
Would the plugin ever receive a mouse or rawKey message? There are a couple of messages that your plugin can subscribe to, see Development Menu -> Plugins -> Plugin Settings. Your plugin would be informed by the IDE about those.

The only way I see to get a IDE wide rawKey message, or a mouseUp message would be a front script. I do not recommend going that way without a thorough understanding what a front or backscript does and how it can easily introduce a lot of "unexpected results".

Your could use command-alt-tab to switch between browse and edit mode (that is what I do) or find a suitable way to hack your IDE.

Kind regards
Bernd

Re: Tool change shortcut

Posted: Mon Jan 15, 2018 9:01 pm
by jacque
Another issue is interference with the IDE's contextual menus. A keyboard combination is safer.