Page 1 of 1
place command
Posted: Sun Jul 21, 2019 9:46 am
by TomKeane123
I'm new to live code and currently doing to 8APP's course.
I have deleted the navigation bar on all of the cards except the first card and
I'm trying to get it to reappear on some of the other cards.
I did a search on the dictionary for the place command but I'm not sure if I'm following the correct syntax or putting the code in the right place.
on the cards I want the navigation bar displayed on to I put:
on preOpencard
place group "Navigation" onto card "stopwatch"
end preOpencard
but this did not work so I tried it on the stack instead of on the card.
on preOpenstack
place group "Navigation" onto card "stopwatch"
end preOpenstack
this also did not work.
does anyone know how to get the navigation bar to display on cards if it is accidentally deleted?
Re: place command
Posted: Sun Jul 21, 2019 10:56 am
by bogs
As far as I can tell, you have the script correctly written, and you are right in that it does not work as the dictionary apparently says it should.
Maybe someone else knows better how this is supposed to work, I never tried it before. My usual method is to just set the group as a background (which will place it on all new cards), and then delete the group from the cards I don't want it on.
Re: place command
Posted: Sun Jul 21, 2019 2:38 pm
by dunbarx
Hi.
When you navigate to an particular card, if the group "navigation" is not present on that card, LC will throw and error. Try something like this(pseudo):
Code: Select all
on preOpencard
place group "Navigation" of cd "anyCardThatContainsGroupNavigation" onto card "stopwatch"
end preOpencard
Do you see? LC is very literal, and it may not know anything about group "navigation" just because it may exist on a card somewhere else in the stack (or on a card in another stack entirely). It has to have it in hand ON THE CURRENT CARD in order to place it somewhere. But if you give it a pathway to where that group lives, it will happily grab it and place it for you.
Craig
Re: place command
Posted: Sun Jul 21, 2019 2:52 pm
by Klaus
Hi all,
When you navigate to an particular card, if the group "navigation" is not present on that card, LC will throw and error.
exactly, but if you want to address a group that is not on the current card but in the stack use
-> background -> bg
GROUPS are counted relative to the card, BACKGROUNDS relative to the stack, so you should script something like:
Code: Select all
on preOpencard
if there is not a grp "Navigation" then
place BG "Navigation" onto this card
end if
end preOpencard
Best
Klaus
Re: place command
Posted: Sun Jul 21, 2019 5:04 pm
by jacque
Also, the place command is permanent and only needs to be done once during development, so you don't need it a preopencard handler. It won't hurt anything but it's redundant.
After it's run once and all the cards have the background in place you can remove it from the script.
Re: place command
Posted: Sun Jul 21, 2019 11:21 pm
by dunbarx
I think what Jacque implies, is that once a group with backGround behavior is in place, any new card will automatically contain it. This is usually an expedient.
Craig
Re: place command
Posted: Sun Jul 21, 2019 11:41 pm
by jacque
dunbarx wrote: ↑Sun Jul 21, 2019 11:21 pm
I think what Jacque implies, is that once a group with backGround behavior is in place, any new card will automatically contain it. This is usually an expedient.
That's true, but actually I was referring to how the preOpenCard handler would try to place the group every time the card opens, which isn't really necessary if it's already there. Klaus' example checks for the background group before placing it, but even that is only necessary during development.
It doesn't really hurt anything regardless.