Page 1 of 1
Accessing grouped objects from card behavior script
Posted: Thu Sep 20, 2018 3:26 am
by beetlejooce
Hi all,
I'm trying to remove some text in some grouped text fields, from a script located in the cards behavior script (I'm using the Levure framework).
Sample code:
Code: Select all
on openCard
local i = 0
start editing group "grpIcons" of card "preferences" of stack "main_window"
-- Clear preferences
repeat while i < 24
local tPreferenceName
local tPreferenceValue
local tPreferenceField
put "ICONS Custom" && i into tPreferenceName
put "fldCustom" & i into tPreferenceField
put tPreferenceValue into fld tPreferenceField of group "grpIcons" of card "preferences" of stack "main_window"
put i + 1 into i
end repeat
stop editing group "grpIcons" of card "preferences" of stack "main_window"
end openCard
I can see the group being opened for editing in the ide, but get a bug at "
put tPreferenceValue into fld tPreferenceField....." of "No such object".
I've tried leaving off the "
of group "grpIcons" of card "preferences" of stack "main_window"" as well as just leaving off the "
of group "grpIcons"", to no avail. The posted script works just fine without the objects being grouped (without the edit group calls obviously).
Where did I go wrong?
Thanks in advance for any assistance.
Re: Accessing grouped objects from card behavior script
Posted: Thu Sep 20, 2018 6:49 am
by jmburnod
Hi,
I believe start editing group change message path
Why do you need editing group ?
Best regards
Jean-Marc
Re: Accessing grouped objects from card behavior script
Posted: Thu Sep 20, 2018 7:52 am
by FourthWorld
Jean-Marc is spot on: editing backgrounds is a mode provided to assist certain layout tasks within the IDE. Nothing prevents you from using it in your scripts, but things are usually simpler without it.
And since you're using a behavior, "me" will refer to the object the script is attached to, which will simplify referencing controls within the card.
Re: Accessing grouped objects from card behavior script
Posted: Thu Sep 20, 2018 3:49 pm
by beetlejooce
I originally had some text sizing code in that handler but removed it for testing, Hence the "start editing group".
I've removed that and tried your suggestion of "me", and all of the stuff from my previous post. Same error. I finally just scrapped it and started over. Of course it works just fine now.
Thanks for the info and suggestions.
Out of curiosity, how does the message path change with "start editing group"? I've always been kind of mystified by how the message path changes and what changes it. I book marked your extending the message path page a loooong time ago!
Re: Accessing grouped objects from card behavior script
Posted: Thu Sep 20, 2018 5:23 pm
by jmburnod
I don't know how LC does this but why i know why i have thought that message path change with editing group.
If you have an object script in a group which calls a card script and you edit the group the first line "go to definition" of contextual menu of script editor looks grey for your object script.
Jean-Marc
Re: Accessing grouped objects from card behavior script
Posted: Thu Sep 20, 2018 6:02 pm
by FourthWorld
beetlejooce wrote: ↑Thu Sep 20, 2018 3:49 pm
I've removed that and tried your suggestion of "me", and all of the stuff from my previous post. Same error. I finally just scrapped it and started over. Of course it works just fine now.
What changed that made it work?
Out of curiosity, how does the message path change with "start editing group"? I've always been kind of mystified by how the message path changes and what changes it.
Everyone is. It's not commonly needed in delivering the end-user experience, so very few people ever have to script for it.
In essence, it works in scripting how it looks in appearance: controls outside the group being edited become unaddressable, and those within the group are temporarily not within the group, since the group and everything outside of it is not there while that mode is active.
Highly specialized, rarely needed, almost always a simpler, cleaner way to do anything other than the one thing that feature was provided for, allowing developers to handle certain layout tasks within the IDE.
Re: Accessing grouped objects from card behavior script
Posted: Fri Sep 21, 2018 5:00 pm
by jacque
When you edit a group, LC creates a temporary card in RAM and copies the objects in the group to it. After you stop editing it copies the revised objects back into the original group and deletes the temporary card.
I don't know what the message path is, or even if there is one beyond the card itself. It isn't clear whether the temporary card is even part of the original stack or not. Group editing is a GUI aid but isn't really intended for uses outside of development since it's possible to do most editing without going into group editing mode.
Re: Accessing grouped objects from card behavior script
Posted: Fri Sep 21, 2018 5:19 pm
by dunbarx
@ Beetlejooce
You do know about the menu "Edit group" in the menubar, right?
This probably does mostly, if not exactly what the "start editing" command drums up.
Craig Newman
Re: Accessing grouped objects from card behavior script
Posted: Sun Sep 23, 2018 3:56 am
by beetlejooce
I'm not really sure what "fixed" it, as I scrapped it and restarted the IDE. Either one of those actions may have been responsible. I know I should have tried each one individually, but I got hasty!
My reason for meddling with "edit group" was really just for laziness. I set the font to bold for the group, and didn't want to have to touch each object inside it to set it to plain. I've since done just that, and have no further issues (at this time!) with my access to group objects.
Thank you for the tips about the message path!