behavior object properties set prop/get prop

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark

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

Re: behavior object properties set prop/get prop

Post by LCMark » Fri Apr 19, 2013 9:05 pm

What's being discussed above covers this case too :)

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

Re: behavior object properties set prop/get prop

Post by mwieder » Fri Apr 19, 2013 9:41 pm

:D Cool. Just wanted to make sure. It's kind of the opposite case of what was discussed, and I'd love to have this in place soon.

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

Re: behavior object properties set prop/get prop

Post by monte » Fri Apr 19, 2013 10:04 pm

Right... hmm.. looks like there's no parse error throwing on setprop/getprop anyway...

Code: Select all

if (type != ST_ID ||
			sp.lookup(SP_COMMAND, te) != PS_NO_MATCH ||
			(sp.lookup(SP_FACTOR, te) != PS_NO_MATCH &&
			te -> type == TT_FUNCTION))
	{
		MCperror->add(PE_HANDLER_BADNAME, sp);
		return PS_ERROR;
	}
It's just never executed because the MCObject set prop/get prop etc doesn't implement it.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

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

Re: behavior object properties set prop/get prop

Post by mwieder » Fri Apr 19, 2013 10:37 pm

...try setting the thumbposition of a button. There's *something* throwing a parse error...

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

Re: behavior object properties set prop/get prop

Post by monte » Sat Apr 20, 2013 12:11 am

ah... ok, I was talking about the setprop/getprop handler existence in the script. Hmm... yeah I see what you mean... the property parser in the different objects might need to default to checking if there's an implemented setprop handler in the object or it's behavior before throwing an error... see.. objectprops.cpp MCObject:setprop
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

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

Re: behavior object properties set prop/get prop

Post by monte » Sun Apr 21, 2013 12:02 am

playing with this last night... pretty cool... I've got it roughly working for set prop but only in properties that MCObject handles... will need to move the code into a method of MCObject and then call the method from the setprop method of each concrete object type. @mwieder I tested and you can override engine properties in the wrong object (I tested thumbposition of button ;-) but if you pass it still throws the error which is cool and what I would expect...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

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

Re: behavior object properties set prop/get prop

Post by monte » Sun Apr 21, 2013 12:45 am

ok, tweaked my code so you can setprop any synonym too...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

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

Re: behavior object properties set prop/get prop

Post by mwieder » Sun Apr 21, 2013 2:18 am

Throwing an error if you pass seems like the right behavior. As long as there's nothing else to catch the message: for instance, set the thumbposition of a button, then pass the message so that the button's group can also do something with it. I could live with that.

Throwing an error if you override an existing property and then pass wouldn't be as cool. Might want to do something to extend the existing behavior beyond just setting the property, and then hand off setting the property itself to the engine.

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

Re: behavior object properties set prop/get prop

Post by monte » Sun Apr 21, 2013 2:28 am

Exactly... if you pass to the engine and the engine can't handle it then there's an error... if you pass and the engine can handle it then it just does what it normally does. It's exactly like passing a custom property setProp. Also, just the same as with custom properties if you explicitly set in the handler then it won't recursively run the setProp handler again... I've just implemented getProp... I'll commit and push it up so you can pull it from my repo if you want to play ;-)
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

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

Re: behavior object properties set prop/get prop

Post by monte » Sun Apr 21, 2013 2:35 am

LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Re: behavior object properties set prop/get prop

Post by phaworth » Sun Apr 21, 2013 2:45 am

Throwing an error if you pass seems like the right behavior. As long as there's nothing else to catch the message: for instance, set the thumbposition of a button, then pass the message so that the button's group can also do something with it. I could live with that.

Throwing an error if you override an existing property and then pass wouldn't be as cool. Might want to do something to extend the existing behavior beyond just setting the property, and then hand off setting the property itself to the engine.
OK, I'm not sure I fully understand this but is the gist that you will be able to set a property of an object even though that object doesn't have that property? If so, I'm not sure I like that, too many opportunities to shoot yourself in the foot. Isn't that what custom properties are for?

Pete

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

Re: behavior object properties set prop/get prop

Post by mwieder » Sun Apr 21, 2013 2:46 am

Thanks. I take it you haven't pushed yet - the latest update seems to be 19 hours ago. I feel like Jacque's timewarp has grabbed hold of me.

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

Re: behavior object properties set prop/get prop

Post by mwieder » Sun Apr 21, 2013 2:49 am

Pete - there are cases where you *can't* set a custom property. As in my example, try setting the thumbposition of a button. It doesn't exist as a built-in property of a button and you can't set it as a custom property. You have to come up with a new naming convention.

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

Re: behavior object properties set prop/get prop

Post by monte » Sun Apr 21, 2013 2:56 am

Basically this will allow us to create custom controls that have the same properties as engine controls.

GitHub seems to be asleep... the branch isn't showing up but it's definitely there... some pages seem to know about it but others don't... maybe there's a cron job or something that updates some of the pages...

Anyway.. here's the commit: https://github.com/montegoulding/liveco ... aa6312b909
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

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

Re: behavior object properties set prop/get prop

Post by mwieder » Sun Apr 21, 2013 3:21 am

Thanks. Pulled. Wow - that's a lot of similar-looking changes.

Locked

Return to “Engine Contributors”