Wide open behaviors

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderator: Klaus

Post Reply
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Wide open behaviors

Post by dunbarx » Mon Jun 07, 2010 10:09 pm

Is it a big thing to think that behaviors might not be limited to buttons? Why not have any object, including stacks, be the repository of a behavior script?

Craig Newman

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Wide open behaviors

Post by FourthWorld » Mon Jun 07, 2010 11:54 pm

I argued for that back when the implementation was still in early beta. As adamant as I was initially I've come to be okay with the implementation as it is, since it really doesn't matter what sort of object holds the script: none of its own properties come into play, since using "me" refers to the instance and not the behavior.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Wide open behaviors

Post by Mark » Thu Jun 10, 2010 9:44 am

Hi,

I believe it would have been more elegant if RunRev had created a special, new object to store parent scripts in. They might have called it a class object, to lure OOP advocates.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Wide open behaviors

Post by FourthWorld » Thu Jun 10, 2010 6:04 pm

Mark wrote:I believe it would have been more elegant if RunRev had created a special, new object to store parent scripts in. They might have called it a class object, to lure OOP advocates.
Agreed. Such things would also make great virtual objects we could use with behaviors to implement more OOP-like architectures.

Hopefully somewhere down the road....
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

ooper
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Mon Aug 17, 2009 12:22 am

Re: Wide open behaviors

Post by ooper » Sun Aug 01, 2010 11:51 pm

I agree. I think that it would be a good thing to have a non-UI object hosting the behavior. Moreover, it would be useful if these could be created dynamically from a prototype --as it is now, but once created the new instance would hold its own runtime state that is privately, protected or globally accessible to the application (e.g., no path to a physical object on a stack). Ideally, these objects could contain behaviors from multiple prototypes. Finally, you could make these objects persistent --or contain hooks to become persistent.

This does not require changing the current Behavior. I still like the current approach, because a behavior is nicely encapsulated. Plus the fact that it lives in a button it can contain unit tests in its mouseUp event and can be copy-and-pasted anywhere!

/Carl

WinstonJenks
Posts: 36
Joined: Fri Jan 01, 2010 12:11 am

Re: Wide open behaviors

Post by WinstonJenks » Sun Sep 19, 2010 9:53 am

If any of you have seen the Toolbook product, this is what they call "shared scripts". And they are kept someplace in the stack not in a UI element. The really nice thing is there is a built-in user interface to select the shared script from the repository of shared scripts. No finding your button, and then typing in the name, misspelling it as you go... But keeping the script in a button is not too bad, but the language has commands to create and delete shared scripts as well. Actually, I think the Rev way is more flexible, but more work too because there is no behavior "picker".

Post Reply