Tool Shed

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Tool Shed

Post by richmond62 » Thu May 07, 2020 9:31 am

I have a button containing this code:

Code: Select all

on mouseEnter
   set the tool to "browse"
end mouseEnter

on mouseLeave
   set the tool to "brush"
end mouseLeave
So, when I move my mouse pointer to click on the button it should change the cursor
to the browse tool, and when I pull away from the button it should change the cursor
to the brush tool.

The script successfully turns the cursor to the brush tool, but seems unable to change it back to the browse tool.

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Tool Shed

Post by bogs » Thu May 07, 2020 10:27 am

Looks like a bug to me. Also looks like it goes all the way back to Mc 2.5 (the original, not the OSS version).
Image

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Tool Shed

Post by jmburnod » Thu May 07, 2020 11:18 am

Hi,
Same result as Richmond here (LC 9.5.0,OSX 10.13)
Best
Jean-Marc
https://alternatic.ch

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Tool Shed

Post by richmond62 » Thu May 07, 2020 11:48 am

I don't think it is a bug, but it is a problem.

I suspect that as soon as the brush tool is set a new empty image is created which overlays the control
containing the mouseLeave command.

Um . . . No . . . that only happens once one does a mouseDown with the brush tool.

In that case it is necessary to find the name of the new image and send it backwards so that it is on a lower layer to the button.

This is a problem because, ideally, the script to do this would be in the newly created image.

Putting this sort of thing into the cardScript does not work:

Code: Select all

on mouseUp
set the name of the last img to "ZZ"
end mouseUp
because the new image overlays the card and traps the mouseUp signal.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Tool Shed

Post by richmond62 » Thu May 07, 2020 12:30 pm

Probably time to 'fess up . . .

I am trying to work up a very primitive drawing "thing" for my wife to use with Jitsi Meet, and myself with Zoom
(for our online teaching stuff) to allow us to draw pictures which our victims can see in real time.
-
Screenshot 2020-05-07 at 14.25.17.png
-
The central idea, such as it is, is that the end-user should be able to change the brushColor
by visiting one of the squares at the top of the window:

Code: Select all

on mouseEnter
   set the tool to "browse"
end mouseEnter

on mouseDown
   set the tool to "brush"
   set the brushColor to the backGroundColor of me
end mouseDown
Attachments
Simple Draw.livecode.zip
Here's the proto-proto-proto stack.
(1.03 KiB) Downloaded 201 times
Last edited by richmond62 on Thu May 07, 2020 2:15 pm, edited 1 time in total.

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: Tool Shed

Post by sphere » Thu May 07, 2020 12:31 pm

I have a stack with similar comands as Richmond.
Don't have it with me at the moment

But i also want to change between the pointer and brushes or pencil.
Have to check tonight if i keep it in mind, see how it works, cause i stopped it then as it does not work well on Android(there is a old bugreport for it) as brushes seemed not to be copied over in the standalone.
I wanted to use it on very big touch screens which have android, but can also work with Windows/Mac using Tuio touch protocol

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Tool Shed

Post by dunbarx » Thu May 07, 2020 2:20 pm

I have forever had a plug-in that allow me to use a right click on my mouse to switch between the browse and pointer tools. Very convenient.

A slight modification, and this works for me:

Code: Select all

switch
      case tKey = 65482 and the tool = "pointer tool" --RIGHT CLICK
         choose "brush tool"
         break
      case tKey = 65482 and the tool = "brush tool"  --RIGHT CLICK
         choose "pointer tool"
         break
But this does not translate to the mouseEnter and mouseLeave messages. So, a bug?

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Tool Shed

Post by dunbarx » Thu May 07, 2020 2:30 pm

Maybe it is not a matter of the mouseEnter or mouseLeave messages.

ALL of the graphic and the paint tools will "lock out" the ability of either of the above messages. With a field somewhere:

Code: Select all

on mouseEnter
   set the tool to "browse"
   put random(99) into fld 1
end mouseEnter

on mouseLeave
   set the tool to "pencil tool"
   put random(99) into fld 1
end mouseLeave
You get a number in the field on mouseEnter, in the browse tool, but once mouseLeave fires the first time (you get another number), neither of those messages are ever sent again, and this seems to apply to all the paint and graphic tools.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Tool Shed

Post by dunbarx » Thu May 07, 2020 2:45 pm

Have not done a lot of testing, but the paint and graphic tools suppress most messages. Not RawKeyWhatever, but most others.The message watcher becomes very quiet when fooling around with those tools.

Is this normal behavior?

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Tool Shed

Post by richmond62 » Thu May 07, 2020 3:51 pm

dunbarx wrote:
Thu May 07, 2020 2:45 pm
the paint and graphic tools suppress most messages.

Is this normal behavior?
All the drawing tools would have to suppress some messages as drawing operations might be interfered with by mouseDown and
mouseUp messages, or, put another way:

maybe mouseDown, mouseStiilDown and so on are used in the operation of the paint tools.

This does not explain the mouseEnter and mouseLeave messages being ignored.

HOWEVER . . . if there were a way to rename the image created when a paint tool is used so that that image can be sent to
the bottom layer of a card so other controls (buttons and so on) could receive mouse signals that would not matter.

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Tool Shed

Post by bogs » Thu May 07, 2020 3:56 pm

Why not reverse that, and layer the button up, since you already know all about the button.
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Tool Shed

Post by richmond62 » Thu May 07, 2020 4:42 pm

bogs wrote:
Thu May 07, 2020 3:56 pm
Why not reverse that, and layer the button up, since you already know all about the button.
Clever, clever. 8)

How do you do that when, while you are using the brush tool you cannot send a mouse message anywhere to
layer the button up?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Tool Shed

Post by dunbarx » Thu May 07, 2020 5:22 pm

How do you do that when, while you are using the brush tool you cannot send a mouse message anywhere to
layer the button up?
Kluge, kluge, kluge.

Code: Select all

on mouseEnter
   set the tool to "browse"
end mouseEnter

on mouseLeave
   checkLoc
   set the tool to "pencil tool"   
end mouseLeave

on checkLoc
   put the mouseLoc into fld 1
   send "checkLoc" to me in 1
end checkLoc
The tool changes, and the mouseLoc appears in fld 1. Now use that information to see if the mouseLoc is within the rect of the button, and act accordingly.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Tool Shed

Post by richmond62 » Thu May 07, 2020 5:34 pm

The tool changes, and the mouseLoc appears in fld 1. Now use that information to see if the mouseLoc is within the rect of the button, and act accordingly.
Ah, but, I then drag my paint brush around for a bit, them mouseUp, and then move my pointer back over the button . . .

. . . by that time the checkloc has been and gone quite some time ago.

Fioch, off to have my supper . . . and then I'll start messing around again.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7392
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Tool Shed

Post by jacque » Thu May 07, 2020 5:48 pm

This has been standard behavior since MC 1.0. Try putting your tool buttons in a stack set to palette mode, I believe that handles the problem for you.

This won't work in mobile apps, it's desktop only.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply