behavior object properties set prop/get prop
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark
Re: behavior object properties set prop/get prop
What's being discussed above covers this case too
-
- 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
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.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: behavior object properties set prop/get prop
Right... hmm.. looks like there's no parse error throwing on setprop/getprop anyway...
It's just never executed because the MCObject set prop/get prop etc doesn't implement it.
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;
}
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
-
- 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
...try setting the thumbposition of a button. There's *something* throwing a parse error...
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: behavior object properties set prop/get prop
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/
Re: behavior object properties set prop/get prop
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/
Re: behavior object properties set prop/get prop
ok, tweaked my code so you can setprop any synonym too...
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
-
- 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
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.
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.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: behavior object properties set prop/get prop
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/
Re: behavior object properties set prop/get prop
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
Re: behavior object properties set prop/get prop
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?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.
Pete
-
- 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
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.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- 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
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.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: behavior object properties set prop/get prop
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
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/
-
- 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
Thanks. Pulled. Wow - that's a lot of similar-looking changes.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev