I would like my widget to detect mouse moves so that I can drag it around based on the current mouse position. I'm tying myself in knots with the syntax. The following seems close but still not working exactly right. I think it has to do with the way I am constructing the arguments in square brackets for the "post" command. Are there any docs explaining arguments and maybe with a couple of examples? Any guidance appreciated.
LCB:
public handler OnMouseMove()
private variable tPoint as Point
private variable tXPointAsString as String
private variable tYPointAsString as String
put the current click position into tpoint
put intToString(the x of tPoint) into tXPointAsString
put intToString(the y of tpoint) into tYPointAsString
post "mouseMove" to my script object with [tXPointAsString,tYPointAsString]
end handler
LCS (in the widget script directly):
on mousemove pX pY
... do some stuff with pX and pY ...
end mousemove
syntax of arguments passing from LCB to LCS
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
Re: syntax of arguments passing from LCB to LCS
Here is what I use for mouseMove. Just replace FormatInt with your intToString.
Code: Select all
variable tLoc as Point
put the mouse position into tLoc
post "mouseMove" to my script object with [FormatInt(the left of my rectangle + the x of tLoc), FormatInt(the top of my rectangle + the y of tLoc)]
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
-
- VIP Livecode Opensource Backer
- Posts: 93
- Joined: Tue Nov 17, 2009 6:47 pm
- Location: Wellington, New Zealand
Re: syntax of arguments passing from LCB to LCS
Very cool tks Trevor
Re: syntax of arguments passing from LCB to LCS
For the last couple of LiveCode 8 developer preview releases, you should now just be able to use:
and it should do the Right Thing -- it shouldn't be necessary to use the workaround "FormatInt" functions any more.
Code: Select all
<number> formatted as string
LiveCode Open Source Team — @PeterTBBrett — peter.brett@livecode.com
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
- Contact:
Re: syntax of arguments passing from LCB to LCS
That is a welcome change. Thanks for letting us know @peter-b.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder