Page 1 of 1

syntax of arguments passing from LCB to LCS

Posted: Fri Feb 12, 2016 12:27 pm
by pthirkell
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

Re: syntax of arguments passing from LCB to LCS

Posted: Fri Feb 12, 2016 12:31 pm
by trevordevore
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)]

Re: syntax of arguments passing from LCB to LCS

Posted: Fri Feb 12, 2016 12:36 pm
by pthirkell
Very cool tks Trevor :D

Re: syntax of arguments passing from LCB to LCS

Posted: Mon Feb 15, 2016 11:30 am
by peter-b
For the last couple of LiveCode 8 developer preview releases, you should now just be able to use:

Code: Select all

<number> formatted as string
and it should do the Right Thing -- it shouldn't be necessary to use the workaround "FormatInt" functions any more.

Re: syntax of arguments passing from LCB to LCS

Posted: Mon Feb 15, 2016 10:21 pm
by trevordevore
That is a welcome change. Thanks for letting us know @peter-b.