Changing Tools

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jsburnett
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 110
Joined: Fri Mar 09, 2007 9:47 pm

Changing Tools

Post by jsburnett » Thu Nov 07, 2013 12:29 am

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

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Changing Tools

Post by Simon » Thu Nov 07, 2013 12:33 am

Hi John.
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!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9664
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Changing Tools

Post by dunbarx » Thu Nov 07, 2013 1:03 am

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

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Changing Tools

Post by Simon » Thu Nov 07, 2013 1:14 am

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.
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Changing Tools

Post by Simon » Thu Nov 07, 2013 1:56 am

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jsburnett
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 110
Joined: Fri Mar 09, 2007 9:47 pm

Re: Changing Tools

Post by jsburnett » Sat Nov 09, 2013 12:14 am

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

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”