Why developers have flat foreheads

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dalkin
Posts: 183
Joined: Wed Jul 04, 2007 2:32 am
Contact:

Why developers have flat foreheads

Post by dalkin » Fri Jul 20, 2007 5:13 am

Banging their heads on the desk when something simple doesn't work in my case. I have 2 buttons on a stack and 1 rectangular image, filled white. The aim is to provide a user with a simple pencil drawing tool and an eraser.

Pencil button:
on mouseDown
choose pencil tool
end mouseDown

on the eraser button:
on mouseDown
choose eraser tool
end mouseDown

on image:
on mouseLeave
choose browse tool
end mouseLeave

The first issue is that when I select 'run' mode and click the 'Pencil' button, the pencil appears but the browse/edit tools are then both deselected. In that mode, I can draw on the image with the pencil but I can't select the eraser because the "on mouseLeave/choose browse tool" isn't working. Has anyone got the time to duplicate this or otherwise offer advice?

Issue 2: if I change the script of the first button to "choose brush tool" it simply doesn't work.

Issue 3: if I select "edit" mode, the script of the rectangle "on mouse leave/choose browse tool ... " continues to run, switching the environment from "edit" to "browse".

(Bang ... bang ... bang ...)

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Fri Jul 20, 2007 9:17 am

Hi dalkin,

implementing drawing capabilities is a bit tricky as your flat forehead can tell ;-)

Looks like these messages "mousedown/leave etc..." are not send with a drawing tool selected.

I did it in the past but used a PALETTE window for the "tools".

Another approach will be to "poll" the mouseloc continuously to act accordingly:

Code: Select all

on mouseup
  choose pencil tool
  send "checktool" to me in 500 millisecs
end mouseup

on checktool
  if within(the rect of img "image to be edited", the mouseloc) then
   send "checktool" to me in 500 millisecs
 else
  choose browse tool
 end if
end checktool
This is not tested, but you will get the picture.


Regards

Klaus


P.S.
Why not give the user the chance to change his mind and use "MOUSEUP" insted of "MOUSEDOWN"? ;-)

dalkin
Posts: 183
Joined: Wed Jul 04, 2007 2:32 am
Contact:

Post by dalkin » Fri Jul 20, 2007 11:36 pm

Thanks for taking the time with this Klaus:

I've discovered that part of the problem is that "on mouseLeave" will work if applied to an image, but not to a graphic. The workaround has been to create a filled (white) rectangle (the graphic) and place it behind a filled (white) image. In this way, the cursor is restored to a browser tool when leaving the editing area - a bit messy, but it seems to work.

The only thing that remains a concern is why selecting a tool from a button with a "choose tool" command crashes the browse/edit environment.

Interestingly "checktool" from your script doesn't appear in the Transcript dictionary. Where did you come by that?

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Sat Jul 21, 2007 9:47 am

Hi dalkin,

oh c'mon, that's a name and handler I invented, could also have called it "howard", but "checktool" sounded more erm... PRO :-D


Best from germany

Klaus

dalkin
Posts: 183
Joined: Wed Jul 04, 2007 2:32 am
Contact:

Post by dalkin » Sat Jul 21, 2007 10:56 am

(Bang ... bang ... bang ... bang ...)

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Sat Jul 21, 2007 11:13 am

LOL :lol:

Have a nice weekend (with or without some aspirin ;-))


Best from germany

Klaus

Post Reply