Questions on frontscript
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Questions on frontscript
Hi all,
I'm trying to make some kind of very basic interface to ease OOP in livecode. Let's say I have a card that represents a namespace, and a bunch of behavior buttons on it.
I'd like to implement a contextual menu to Create New Class, Create SubClass, Delete Class, Edit Script etc (just like the Ctrl-Shift-RightClick thing)
When must I insert the frontscript to acheive this? Do I need to remove it at some point?
How does the frontscript know which control was clicked?
Regarding the "Delete Class" action, If I do it with this contextual menu, it's all right... But what if I press the delete key? (I understand there is no userLevel anymore...) I cannot use the deleteButton message from outside the button itself, and I'd like to avoid that...
The point of course is to keep track of all the classes in that namespace (in a card custom property) so that I can't create a subclass with no parent class or delete a class that have subclasses...)
Not sure if my questions are relevant. Thanks for any nudge,
Fred.
I'm trying to make some kind of very basic interface to ease OOP in livecode. Let's say I have a card that represents a namespace, and a bunch of behavior buttons on it.
I'd like to implement a contextual menu to Create New Class, Create SubClass, Delete Class, Edit Script etc (just like the Ctrl-Shift-RightClick thing)
When must I insert the frontscript to acheive this? Do I need to remove it at some point?
How does the frontscript know which control was clicked?
Regarding the "Delete Class" action, If I do it with this contextual menu, it's all right... But what if I press the delete key? (I understand there is no userLevel anymore...) I cannot use the deleteButton message from outside the button itself, and I'd like to avoid that...
The point of course is to keep track of all the classes in that namespace (in a card custom property) so that I can't create a subclass with no parent class or delete a class that have subclasses...)
Not sure if my questions are relevant. Thanks for any nudge,
Fred.
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Questions on frontscript
FrontScripts can be good for this, but even more OOP-like would be to use behaviors. See the "behavior" entry in the Dictionary, and check out this Lesson:
http://lessons.runrev.com/s/lessons/m/4 ... -behaviors
You will have questions; please post them here - many people have questions about behaviors, but some are too shy to ask.
Using behaviors can be a little mind-bending at first, but I believe that once you get the hang of using them you'll find them a good fit for what you want to do.
http://lessons.runrev.com/s/lessons/m/4 ... -behaviors
You will have questions; please post them here - many people have questions about behaviors, but some are too shy to ask.
Using behaviors can be a little mind-bending at first, but I believe that once you get the hang of using them you'll find them a good fit for what you want to do.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Questions on frontscript
Hi.
You are asking several interesting questions. What Richard suggested addresses one important aspect of the program, though you took another tack entirely.
Can you tell us a little more about what you have in mind with these "class" makers and deleters?
Craig Newman
You are asking several interesting questions. What Richard suggested addresses one important aspect of the program, though you took another tack entirely.
Can you tell us a little more about what you have in mind with these "class" makers and deleters?
Craig Newman
Re: Questions on frontscript
Sorry I wasn't clear. I AM using behaviors, and nested behaviors for subclasses, and setprops for property inheritance/overriding, which is very cool btw!
Before you ask, I read this too, good article btw.
http://www.fourthworld.com/embassy/arti ... _path.html
But my question was on frontscripts! Can't find any lesson/example/discussion about them...
What I would like is something that helps me keep track of all the behavior IDs to prevent me from doing dumb stuff like
ask for the name of the new subclass
ask for the parent class ID -- that would be given by the popup menu ("How does the frontscript know which control was clicked?")
check if parent class exists
check if there is already a subclass with this name
if all is ok then create the new behavior button with its name and set its behavior to the parent class ID
add this to the uClassList of the card
or a deleteClass handler :
check if any button on the card has this button as behavior
alert user ...
actually delete the button, maybe back it up somewhere :roll:
remove it from the uClassList of the card
hence the question : how can I trigger this handler regardless of the way I delete the button. And without adding a deletButton in a "Class behavior button" (I'd like to keep the behaviors chain to the job and not add such utilities)
I think using behaviors is very intuitive if you come from an oop language, probably not if you come from pure HC.
Before you ask, I read this too, good article btw.
http://www.fourthworld.com/embassy/arti ... _path.html
But my question was on frontscripts! Can't find any lesson/example/discussion about them...
What I would like is something that helps me keep track of all the behavior IDs to prevent me from doing dumb stuff like
for instance I have a createSubClass handler such as:create a subclass with no parent class or delete a class that have subclasses...
ask for the name of the new subclass
ask for the parent class ID -- that would be given by the popup menu ("How does the frontscript know which control was clicked?")
check if parent class exists
check if there is already a subclass with this name
if all is ok then create the new behavior button with its name and set its behavior to the parent class ID
add this to the uClassList of the card
or a deleteClass handler :
check if any button on the card has this button as behavior
alert user ...
actually delete the button, maybe back it up somewhere :roll:
remove it from the uClassList of the card
hence the question : how can I trigger this handler regardless of the way I delete the button. And without adding a deletButton in a "Class behavior button" (I'd like to keep the behaviors chain to the job and not add such utilities)
I think using behaviors is very intuitive if you come from an oop language, probably not if you come from pure HC.
Re: Questions on frontscript
There I fixed a quick example...
Sorry for the mess!
hmm can't see the attachement
here's a url
https://www.dropbox.com/s/1sn1j76w1ulx0 ... k.livecode
Sorry for the mess!
hmm can't see the attachement
here's a url
https://www.dropbox.com/s/1sn1j76w1ulx0 ... k.livecode
Re: Questions on frontscript
Hmm... I guess I'm not making much sense!