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

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 6:06 pm

Jacque.

Interesting. Palette mode makes the messages go down?

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 6:09 pm

Jacque usually has the best advice.

I have second-best advice, usually. This works. Just for visuals, make the field a little taller:

Code: Select all

on mouseEnter
   put "browse" into fld 1
   set the tool to "browse"
end mouseEnter

on mouseLeave
   checkLoc
   put "pencil" into fld 1
   set the tool to "pencil tool"   
   
end mouseLeave

on checkLoc
   if the optionKey is down then exit to top
   put the mouseLoc into line 2 of fld 1
   if the mouseLoc is within the rect of btn 1 then set the tool to "browse" else set the tool to "pencil"
       send "checkLoc" to me in 1
end checkLoc

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 6:15 pm

dunbarx wrote:
Thu May 07, 2020 6:06 pm
Interesting. Palette mode makes the messages go down?
Palettes are locked to browse mode.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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 6:50 pm

Palettes are locked to browse mode.
But then how would Richmond select a graphic tool? Such a command would be ignored.

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 7:07 pm

This is like grasping for a rabbit's tail through a solid concrete wall.

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 7:11 pm

Richmond.

Did you try my kluge? It likely needs tweaking, but seems to load the right tool at the right time.

A running "send in time" gadget seems to bypass the message locking problem. In a sense, "messages" are sent during graphic tool time. Even if you roll your own, you will likely need to do something similar.

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 7:18 pm

No, not yet, and had a long day, so going to have a good, long soak in the bath, and I'll give it
a bash tomorrow.

Although the whole thing that one cannot switch back out of a paint tool easily does strike me as a bit odd.

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 7:55 pm

dunbarx wrote:
Thu May 07, 2020 6:50 pm
Palettes are locked to browse mode.
But then how would Richmond select a graphic tool? Such a command would be ignored.
Not exactly. While clicking in a palette, is reacts as though you have the browse tool selected and the cursor changes to browse. When you mouse away, it returns to whatever it was. You can change the tool and when you leave the palette, the current tool should be active.

Note I don't have time to test this, I'm deep in the weeds over here, but it's worth a try.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Tool Shed

Post by sphere » Thu May 07, 2020 8:17 pm

i have a graphic on which i can move other graphics to a certain area, but on which i also can draw. It's not perfect, but works a certain bit.
I also change layers, and copy a script to the new graphic. Maybe it's of use for your problem.
I a few buttons Like Draw and Move items(stop drawing)
Button draw:

Code: Select all

global gColor,gLSize,gTrans
on mouseUp
   if there is not a graphic"draw" then
   create graphic"draw"
   --set the width of graphic"draw" to the width of image"nl+road.svg" --not needed as the graphic becomes as big as you draw
   --set the height of graphic"draw" to the height of image"nl+road.svg"
   --set the loc of graphic "draw" to the loc of image"nl+road.svg"
   set the layer of graphic"draw" to top
   choose polygon tool -- or pencil
  --set the defaultCursor to arrow
   set the script of graphic ("draw") to \
         "global gColor,gLSize" & cr & \
         "on mouseLeave" & cr & \
           "choose browse tool"  & cr & \
          "end mouseLeave" & cr & cr &  \
          "on mouseEnter" & cr & \
         "set the foregroundcolor of me to gColor" & cr & \
         "set the lineSize to gLSize" & cr & \
         "choose polygon tool" & cr & \  --or pencil
         "end mouseEnter" & cr & cr & \
         "on mouseUp" & cr & \
           "choose pointer tool"  & cr & \
          "end mouseUp" & cr & cr &  \
         "on mouseDown theButton" & cr & \
         "if theButton is 1 then" & cr & \
      "choose polygon tool" & cr & \
         "else" & cr & \
         "if theButton is 3 then" & cr & \
         "choose Eraser tool" & cr & \
         "end mouseDown"
   --set the penColor to gColor
   set the foregroundcolor of graphic"draw" to gColor
   set the opaque of  graphic"draw" to false
   set the lineSize of graphic"draw" to gLSize
   set the blendLevel of graphic"draw" to gTrans
   set the style of graphic"draw" to "polygon"
   set the disabled of btn"Erase" to false
else
   set the layer of graphic"draw" to top
   choose polygon tool
   --set the defaultCursor to arrow
    set the script of graphic ("draw") to \
         "global gColor,gLSize" & cr & \
         "on mouseLeave" & cr & \
           "choose browse tool"  & cr & \
          "end mouseLeave" & cr & cr &  \
          "on mouseEnter" & cr & \
         "set the foregroundcolor of me to gColor" & cr & \
         "set the lineSize to gLSize" & cr & \
         "choose polygon tool" & cr & \
          "end mouseEnter" & cr & cr & \
          "on mouseUp" & cr & \
           "choose pointer tool"  & cr & \
          "end mouseUp" & cr & cr &  \
         "on mouseDown theButton" & cr & \
         "if theButton is 1 then" & cr & \
      "choose polygon tool" & cr & \
         "else" & cr & \
         "if theButton is 3 then" & cr & \
         "choose Eraser tool" & cr & \
         "end mouseDown"
   --set the penColor to gColor
   set the foregroundcolor of graphic"draw" to gColor
   set the lineSize of graphic"draw" to gLSize
   set the opaque of  graphic"draw" to false
   set the blendLevel of graphic"draw" to gTrans
   set the style of graphic"draw" to "polygon"
   set the disabled of btn"Erase" to false
   end if
end mouseUp

on mouseEnter
  -- send "choose browse tool" to me in 1 tick
  -- set the defaultCursor to arrow
end mouseEnter
button move (this stops the drawing)

Code: Select all

on mouseUp
   choose Browse tool
   set the layer of graphic"draw" to 2   
end mouseUp

#on mouseEnter
   #send "choose browse tool" to me in 1 tick
  -- set the defaultCursor to arrow
#end mouseEnter
I just copied it from my stack.
Is this something you can use?

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 9:28 pm

At the risk of seeming churlish, for the moment, at least, I have ignored all the suggestions here.

[Currently in bed using my Xubuntu 20.04 64-bit laptop]

I have created a blank image "ZZ" and set it to layer 1.

I have this code in the cardScript:

Code: Select all

on mouseUp
   set the tool to "browse"
end mouseUp

on mouseDown
   set the tool to "brush"
end mouseDown
predictably it allows the mouseDown command to work, but NOT the mouseUp command.

At least the drawing now takes place on a named image behind my buttons.
-
snap2.png
Attachments
Simple Draw.livecode.zip
It's a long, long way to Tipperary.
(14.54 KiB) Downloaded 200 times

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 9:41 pm

Now if I put something that feels intuitively OK in a button:

Code: Select all

on mouseUp
   set the tool to "brush"
   wait 5 secs
   set the tool to "browse"
end mouseUp
the set the tool to "browse"also does not work.

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 10:56 pm

Richmond.

You are probably asleep.

This makes sense in light of the new knowledge that paint and graphic tools shut down the whole world just like COVID-19. Commands are useless once that sort of tool is open.

Craig

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

Re: Tool Shed

Post by richmond62 » Fri May 08, 2020 8:15 am

dunbarx wrote:
Thu May 07, 2020 10:56 pm
Richmond.

You are probably asleep.

This makes sense in light of the new knowledge that paint and graphic tools shut down the whole world just like COVID-19. Commands are useless once that sort of tool is open.

Craig
Yes, I was, but, oddly enough, now being the morning in these parts, I am awake and reading your message:

"new knowledge" . . . I'm not sure how 'new' it is, or that people who have
encountered it in the past have shrugged their shoulders and not made a noise.

"Commands are useless once that sort of tool is open."

You have got to love the in-built documentation:

for what it states,

for what it states which is unbelievably out-of-date

and

for what it does not state.

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

Re: Tool Shed

Post by richmond62 » Fri May 08, 2020 8:23 am

Slightly tangential, but trying to set up a button to generate a new image and set it to layer 1 . . . rocket science.

So wondering why this does NOT work:

Code: Select all

on mouseUp
   create image "ZZ"
end mouseUp
MacOS 10.15.5 beta 3, LC 9.5

Aha: the 'mouseUp' statement in the card is blocking that. 8)

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

Re: Tool Shed

Post by bogs » Fri May 08, 2020 8:40 am

richmond62 wrote:
Fri May 08, 2020 8:23 am
Aha: the 'mouseUp' statement in the card is blocking that.
I just woke up, since it is now what is largely considered the middle of the night here, but I am curious how you determined that a mouseUp event on a card is blocking a mouseUp event in a button script which, as far as I can think at the moment is impossible :shock:
Image

Post Reply