FEATURE_INHERITED_PARENTSCRIPTS

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, LCMark

Post Reply
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2826
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by mwieder » Mon Jun 03, 2013 7:09 pm

OK - I did a bit more experimenting and it's trickier than I thought. I hadn't thought of sending or calling directly into behavior scripts before rather than just inheriting the scripts. I confess I can't think of a problem that this solves, though. Now I'm coming around to Dar's request for a "caller" property that would unambiguously return a reference to the object that originated the request, whether it's a send/dispatch, call, or direct or inherited command invocation.

...and we still need an object syntax for the object the script is running in.

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1033
Joined: Thu Apr 11, 2013 11:27 am

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by LCMark » Tue Jun 04, 2013 8:34 am

OK - I did a bit more experimenting and it's trickier than I thought. I hadn't thought of sending or calling directly into behavior scripts before rather than just inheriting the scripts. I confess I can't think of a problem that this solves, though. Now I'm coming around to Dar's request for a "caller" property that would unambiguously return a reference to the object that originated the request, whether it's a send/dispatch, call, or direct or inherited command invocation.
There's no need to send or call directly into a behavior script to see the different...

Code: Select all

   group 1 -> behavior 1
     button 1
     button 2
Let's say behavior 1 defines a handler 'foobar', then doing in button 1:

Code: Select all

  on mouseUp
    foobar
  end mouseUp
Will result in foobar being (eventually) invoked in group 1 with 'the target' button 1, and 'me' group 1.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2826
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by mwieder » Tue Jun 04, 2013 5:29 pm

Good point. I forgot about group behaviors in this context.

...although "me" referencing a different object than the actual object containing the script sounds a bit like something out of Monty Python...

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 960
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by trevordevore » Mon Jul 29, 2013 11:15 pm

I'm wondering if any more thought has been put into 'the scriptObject' idea discussed in this thread. I have a custom control that has some supporting controls on the same card as the behavior button. In order to use these supporting controls I need to get a reference to the behavior button. Having a reference (like 'the scriptObject') would be an elegant way to achieve this. Parsing the executionContexts is, well, less elegant.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1561
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by monte » Tue Jul 30, 2013 12:08 am

Well... we had a chat about syntax then lost the plot. I still like 'this behavior'... BTW recursively parsing the behavior property might be an option too.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 960
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by trevordevore » Tue Jul 30, 2013 12:39 am

BTW recursively parsing the behavior property might be an option too.
True. This would require some hard coding of names, however, wouldn't it? Since you have no way of knowing which behavior is the custom controls then you would have to check the name of each behavior control.
I still like 'this behavior'
What about 'this me'? ;-)
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1561
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by monte » Tue Jul 30, 2013 12:56 am

True. This would require some hard coding of names, however, wouldn't it? Since you have no way of knowing which behavior is the custom controls then you would have to check the name of each behavior control.
I was thinking you would need to tag your behavior object in some way so you could identify it. Either a custom property value or just the name:

Code: Select all

put findBehavior(the behavior of me,"com.bluemango.widget") into theScriptObject

Code: Select all

function findBehavior pObject,pClass
      if the short name of pObject is pClass or pObject is empty then return pObject
      return findBehavior(the behavior of pObject,pClass)
end
What about 'this me'?
I'm sold ;-)
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 960
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by trevordevore » Tue Jul 30, 2013 12:59 am

Ah, that method will work well enough until we get some sort of better reference.
Trevor DeVore
ScreenSteps - http://www.screensteps.com

Levure Application Framework: https://github.com/trevordevore/levure
LiveCode Resources for Developers: http://livecode.bluemangolearning.com

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1033
Joined: Thu Apr 11, 2013 11:27 am

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by LCMark » Wed Jul 31, 2013 12:04 pm

Well... we had a chat about syntax then lost the plot. I still like 'this behavior'... BTW recursively parsing the behavior property might be an option too.
I think it was a case of - we might need this at some point, but since we couldn't decide on firm syntax it was left hanging.

It's easy to add - if we can decide on syntax :)

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1561
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by monte » Thu Aug 01, 2013 1:07 am

We're settled on 'this me' ;-)
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1033
Joined: Thu Apr 11, 2013 11:27 am

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by LCMark » Mon Aug 05, 2013 11:30 am

Seems as good as anything else that's been suggested so far - implemented and should be fine to go into 6.1.1 (feature-this_me branch in runrevmark).

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1561
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by monte » Mon Aug 05, 2013 11:39 am

Lol... Serves us right for joking around Trevor ;-)
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1033
Joined: Thu Apr 11, 2013 11:27 am

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by LCMark » Mon Aug 05, 2013 12:12 pm

Lol... Serves us right for joking around Trevor ;-)
It's easy enough to change to 'this behavior' (or even 'this script'?) - it just means changing the 'skip_token()' line. I guess we can just wait and see what the reaction is to 'this me', and see if anybody comes up with a better suggestion :)

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5113
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by jacque » Mon Aug 05, 2013 6:28 pm

HyperCard had a script error that said, "Script too silly to parse."

I kind of get that same reaction with "this me". Maybe it would make more sense in context. :)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2826
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: FEATURE_INHERITED_PARENTSCRIPTS

Post by mwieder » Tue Aug 06, 2013 7:24 pm

You want context?
If you google "this me" it suggests "this means war".

Post Reply

Return to “Engine Contributors”