OK...
I feel a little stupid asking this...
I am trying to write a part of an app that draws a line on the card.
It should be simple, and there should be a thousand examples/ tutorials about it, but damned if I can find one!!!
Here's what I want to do:
Click on screen and hold down mouse, start drawing a line, move the mouse to a new location on screen, release mouse button and finish drawing the line.
Simples!
Damned if I can get the right handlers.
script should look something like this:
global tPointsList
on mousedown
put the mouseloc into tPointsList --find the startpoint
end mousedown
on mouseup
put the mouseloc after tPointsList --find the endpoint
set the points of graphic "Line01" to tPointsList --draw the line between startpoint and endpoint
end mouseup
There's obviously more to do to create the line, give it properties etc. but I have found and trested that script...
I gather that mousedown, mouseup doesn't work because I'm mixing/ splitting handlers etc.
DragStart, DragEnd doesn't work because that's a drag and drop thing.
I would be happy with some way of clicking and entering mouseloc into list, then clicking again, and adding to list, but can't work out how to track multiple mouse clicks.
Surely there's an easy way of doing this...
Assistance please?
XdM
Drawing a Line Graphic
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Drawing a Line Graphic
Hi Xero,
"the points of grc XYZ" is a CR delimited list of a pairs of numbers!
If in doubt, ALWAYS consult the dictionary!
So this will do the trick, you need to already have a graphic name "Line01" on your card!
Put this into the crad script:
Tested and works!
Best
Klaus
"the points of grc XYZ" is a CR delimited list of a pairs of numbers!
If in doubt, ALWAYS consult the dictionary!
So this will do the trick, you need to already have a graphic name "Line01" on your card!
Put this into the crad script:
Code: Select all
## No need for a GLOBAL, LOCAL will do!
local tPointsList
on mousedown
put the mouseloc into tPointsList --find the startpoint
end mousedown
on mouseup
## See above!
put CR & the mouseloc after tPointsList --find the endpoint
set the points of graphic "Line01" to tPointsList --draw the line between startpoint and endpoint
end mouseup
Best
Klaus
Re: Drawing a Line Graphic
You're some sort of magickian Klaus.
I am sure I had something like that, but it wasn't working!!!
The dictionary is extremely difficult to use if you don't know exactly what you are looking for, and tutorials/ examples are the same... That's what's driving me insane...
I knew I had to create a list with the points in it and then assign that list to an object, but was having issues with the CR getting it on to second line...
I might write a tutorial on it and leave it here for others...
Thanks again.
You're a Godsend Klaus!
XdM
I am sure I had something like that, but it wasn't working!!!
The dictionary is extremely difficult to use if you don't know exactly what you are looking for, and tutorials/ examples are the same... That's what's driving me insane...
I knew I had to create a list with the points in it and then assign that list to an object, but was having issues with the CR getting it on to second line...
I might write a tutorial on it and leave it here for others...
Thanks again.
You're a Godsend Klaus!
XdM
Re: Drawing a Line Graphic
Hi Xero,
you're welcome!
For further worshipping etc. please use this thread:
http://forums.livecode.com/viewtopic.php?f=5&t=31001
Best
Klaus
you're welcome!
For further worshipping etc. please use this thread:
http://forums.livecode.com/viewtopic.php?f=5&t=31001
Best
Klaus