Page 1 of 1

Changing Tools

Posted: Thu Nov 07, 2013 12:29 am
by jsburnett
Hi all,
I am trying to write a stack/script that imports a snap shot, creating a new image, that the user can manipulate, ie... 'draw' on the image with the pencil, 'move' the image with the 'pointer', etc.... (Importing the image is easy with the "import snapshot" command).

Anyway, I am trying to come up with a way for the user to change 'tools' - including browse, pointer, pencil, eraser.

The mouse.. "up, down, enter, leave" commands do not behave the same or "trigger" the same "messages" depending the tool in use.
I've tried setting up buttons that have a mouseUp script that changes the "tool" ... but as expected when the "tool" is the pencil, I can not 'click' on a button with a mouseUp script and get it to 'work' because the mouseUp message is not generated (it is generated only when the browse tool is in use). So once I change the tool to the pencil, I can't change it back.

Hopefully I am somewhat clear...

So, how would you let a user to change tools in a stack?

Sorry if this is real basic stuff. Would appreciate an answer.

Thanks in advance.
John

Re: Changing Tools

Posted: Thu Nov 07, 2013 12:33 am
by Simon
Hi John.
In the buttons on mouseEnter choose browes tool?
Does that work for you?

Simon

Re: Changing Tools

Posted: Thu Nov 07, 2013 1:03 am
by dunbarx
Hi.

If mouseEnter is one of the only messages that gets sent when using the pointer tool, this sort of works. It seems a bit nervous, though. Maybe you can talk it down. In the card script:

Code: Select all

on mouseEnter
   checkForMouseDown the short name of the target
end mouseEnter

on checkForMouseDown tTarget
   if the mouse is down then
      put tTarget && random (99) && the tool
      exit to top
   else
      send "checkForMouseDown" && tTarget to me in 1
   end if
end checkForMouseDown
Craig

If you click around for a while

Re: Changing Tools

Posted: Thu Nov 07, 2013 1:14 am
by Simon
Ok I think I have it.
Make sure your buttons are outside of the image area and put this into the image script

Code: Select all

on mouseLeave
   choose browse tool
end mouseLeave
Simon
Edit: Nah, I don't like that because it ruins the work flow.

Re: Changing Tools

Posted: Thu Nov 07, 2013 1:56 am
by Simon
OK in addition to the above but with

Code: Select all

on mouseEnter
   put the cTool of this stack into tOldTool
   choose tOldTool tool
end mouseEnter
in the image script as well.

Set the custom property cTool to the name of the tool in the on mouseUp button script.

There is still a small problem when detecting the mouseEnter, you'll see it.

Simon

Re: Changing Tools

Posted: Sat Nov 09, 2013 12:14 am
by jsburnett
Hi,
Thanks for your suggestions.
I was playing with the 'Message Watcher' under the development menu and noted that the mouseEnter message is created/passed when moving the mouse into a stack irregardless of the tool, which is not the case for buttons, fields. So I made a substack with the script triggered by the message mouseEnter, choose browse tool, in the stack script and buttons with mouseUp scripts to change/choose pencil tool, eraser tool, etc.. It works and I'm happy. :-)

Thanks,

John