Changing Tools
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Changing Tools
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
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
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Changing Tools
Hi John.
In the buttons on mouseEnter choose browes tool?
Does that work for you?
Simon
In the buttons on mouseEnter choose browes tool?
Does that work for you?
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- VIP Livecode Opensource Backer
- Posts: 9664
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Changing Tools
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:
Craig
If you click around for a while
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
If you click around for a while
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Changing Tools
Ok I think I have it.
Make sure your buttons are outside of the image area and put this into the image script
Simon
Edit: Nah, I don't like that because it ruins the work flow.
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
Edit: Nah, I don't like that because it ruins the work flow.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Changing Tools
OK in addition to the above but with
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
Code: Select all
on mouseEnter
put the cTool of this stack into tOldTool
choose tOldTool tool
end mouseEnter
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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Changing Tools
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
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