syntax of arguments passing from LCB to LCS

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

Post Reply
pthirkell
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 93
Joined: Tue Nov 17, 2009 6:47 pm
Location: Wellington, New Zealand

syntax of arguments passing from LCB to LCS

Post by pthirkell » Fri Feb 12, 2016 12:27 pm

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

trevordevore
VIP Livecode Opensource Backer
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

Post by trevordevore » Fri Feb 12, 2016 12:31 pm

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

pthirkell
VIP Livecode Opensource Backer
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

Post by pthirkell » Fri Feb 12, 2016 12:36 pm

Very cool tks Trevor :D

peter-b
Posts: 182
Joined: Thu Nov 20, 2014 2:14 pm
Location: LiveCode Ltd.

Re: syntax of arguments passing from LCB to LCS

Post by peter-b » Mon Feb 15, 2016 11:30 am

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.
LiveCode Open Source Team — @PeterTBBrett — peter.brett@livecode.com

trevordevore
VIP Livecode Opensource Backer
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

Post by trevordevore » Mon Feb 15, 2016 10:21 pm

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

Post Reply

Return to “LiveCode Builder”