Move object forward/backward
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Move object forward/backward
Hi all,
I have a column of buttons laid out neatrly on a rectangle, whos laid-out size is limited. I have more buttons to display than there is room for. So, I labelled the last button 'More', so the user can access more buttons. I have placed the cannot-be-accommodated buttons, each one, behind one of the displayed buttons, and I have been trying to write an 'on mouse up' command that will bring forward the backlying buttons. I see that there is a menu option in the inspector, object>move forward, and I have been trying to invoke this in my 'More' button code - with a notable lack of success ! Would anyone help me on this ?
Please ?
I have a column of buttons laid out neatrly on a rectangle, whos laid-out size is limited. I have more buttons to display than there is room for. So, I labelled the last button 'More', so the user can access more buttons. I have placed the cannot-be-accommodated buttons, each one, behind one of the displayed buttons, and I have been trying to write an 'on mouse up' command that will bring forward the backlying buttons. I see that there is a menu option in the inspector, object>move forward, and I have been trying to invoke this in my 'More' button code - with a notable lack of success ! Would anyone help me on this ?
Please ?
Re: Move object forward/backward
Hi CAsba,
that "menu option" is in the PROJECT Browser, not in the inspector and it will only affect the LAYER of an object,
so this may not be the way to go.
I would do it like this:
1. Create two or more groups of buttons and show/hide them
OR
2. Arrange ALL of your buttons as you need like
XX XX XX
XX XX XX
XX XX XX
...
XX XX XX
and then GROUP all these buttons, resize the group to your needs and just show its scrollbar.
OR
3. Just create a group from your cannot-be-accommodated buttons and only show/hide that accordingly.
Almost identical to you initial idea, but easier since we only have to deal with ONE object, the group of buttons.
Best
Klaus
P.S.
The correct name of the handler is -> on mouseup (mouseup = ONE word!)
that "menu option" is in the PROJECT Browser, not in the inspector and it will only affect the LAYER of an object,
so this may not be the way to go.
I would do it like this:
1. Create two or more groups of buttons and show/hide them
OR
2. Arrange ALL of your buttons as you need like
XX XX XX
XX XX XX
XX XX XX
...
XX XX XX
and then GROUP all these buttons, resize the group to your needs and just show its scrollbar.
OR
3. Just create a group from your cannot-be-accommodated buttons and only show/hide that accordingly.
Almost identical to you initial idea, but easier since we only have to deal with ONE object, the group of buttons.
Best
Klaus
P.S.
The correct name of the handler is -> on mouseup (mouseup = ONE word!)
-
- Livecode Opensource Backer
- Posts: 10095
- Joined: Fri Feb 19, 2010 10:17 am
Re: Move object forward/backward
Personally I'd have 2 sets of buttons in 2 groups so you could
set the LAYER of each group of buttons when you needed them.
-
set the LAYER of each group of buttons when you needed them.
-
- Attachments
-
- Layer-Cake.livecode.zip
- Stack.
- (1.12 KiB) Downloaded 132 times
Re: Move object forward/backward
You must definitely use multiple groups. That is what they are for.
And all you need to do is something like:
Craig
And all you need to do is something like:
Code: Select all
om mouseUp
if the visible of group "ButtonGroupOne" is"true" then
set the visible of group "ButtonGroupOne" to "false"
set the visible of group "ButtonGroupOTwo" to "true"
else
set the visible of group "ButtonGroupOne" to "true"
set the visible of group "ButtonGroupOTwo" to "false"
end if
Re: Move object forward/backward
It occurred to me that you might have more that two such groups. Can you handle (no pun intended) more?
Craig
Craig
Re: Move object forward/backward
Hi Klaus,
Thanks for your reply.
I don't know how to make a group. I read up on it and it said to select objects then put them in a group. I don't know how to select more than one object (I understand 'select' to mean right clicking it.) Can you advise me what I should be doing to 'select' more than one object ?
Am I to understand that Livecode does not have the facility of coding for moving objects forward/backward at all ? I ask because I was planning on using that method for future situations I had planned.
I found the 'menu option' in the object inspector menu, the four options were send to back, bring to front, move backward, move forward. I just tried it out, I placed one button 'on top of' another and clicked on the menu options 'bring forward' and 'send to back' and the buttons alternated in being visible.
It is disappointing that there is a facility to do what I require, but that the facility cannot be coded. (Are you certain it can't be coded ?)
Thanks for your reply.
I don't know how to make a group. I read up on it and it said to select objects then put them in a group. I don't know how to select more than one object (I understand 'select' to mean right clicking it.) Can you advise me what I should be doing to 'select' more than one object ?
Am I to understand that Livecode does not have the facility of coding for moving objects forward/backward at all ? I ask because I was planning on using that method for future situations I had planned.
I found the 'menu option' in the object inspector menu, the four options were send to back, bring to front, move backward, move forward. I just tried it out, I placed one button 'on top of' another and clicked on the menu options 'bring forward' and 'send to back' and the buttons alternated in being visible.
It is disappointing that there is a facility to do what I require, but that the facility cannot be coded. (Are you certain it can't be coded ?)
Re: Move object forward/backward
Hi again,
Not to worry, I found the answer in 'talking livecode' Post by david_fff » Sat Jun 27, 2015 7:52 pm, with a simple answer.
My queries about selecting and grouping remain, though..
Not to worry, I found the answer in 'talking livecode' Post by david_fff » Sat Jun 27, 2015 7:52 pm, with a simple answer.
My queries about selecting and grouping remain, though..
-
- Livecode Opensource Backer
- Posts: 10095
- Joined: Fri Feb 19, 2010 10:17 am
Re: Move object forward/backward
To select multiple objects click on each one while holding the SHIFT button down.
You'll find the GROUP command in the menus.
You'll find the GROUP command in the menus.
Re: Move object forward/backward
Got it ! Many thanks.
Re: Move object forward/backward
Hi CAsba,
I really advice to go through one or all of these stack to get hte basics of LC:
http://www.hyperactivesw.com/revscriptc ... ences.html
2. Click on the first object you want to select
3. Hold the SHIFT key and select all other controls you need
4. With all object selected use STRG-G as a shortcut or use -> Menu: Object: Group Seleted
Yun can of course e.g.:
Lot of typing, but if these btns are grouped it is a one-liner:
Example:
You have two buttons "b1" and b2" and both have identical dimensions width/height and also identical LOCs.
If the layer of btn "b1" = 1 and layer of "b2" = 2 then "b1" will be UNDER "b2"
If the layer of btn "b2" = 1 and layer of "b1" = 2 then "b2" will be UNDER "b1"
Get it? Just like the "levels" in Photoshop or any other image editing application
Important hint for groups!
The global property "selectgroupedcontrols", in Menu: Edit: Select Grouped Controls, will make groups appear as ONE object.
If it is unchecked, when you select the group with the POINTER tool, the group will be treated as ONE object.
If CHECKED then you can select all objects in the group as individual objects.
Just try it out to get used to it!
Best
Klaus
I really advice to go through one or all of these stack to get hte basics of LC:
http://www.hyperactivesw.com/revscriptc ... ences.html
1. Select the arrow pointer (Edit tool, topright oin the TOOLS paletteCAsba wrote: ↑Tue Oct 18, 2022 10:12 amI don't know how to make a group. I read up on it and it said to select objects then put them in a group. I don't know how to select more than one object (I understand 'select' to mean right clicking it.) Can you advise me what I should be doing to 'select' more than one object?
2. Click on the first object you want to select
3. Hold the SHIFT key and select all other controls you need
4. With all object selected use STRG-G as a shortcut or use -> Menu: Object: Group Seleted
of course this is possible, but using groups makes it easier to script!
Yun can of course e.g.:
Code: Select all
...
## Move buttons forward = raising their layer number on the card
set the layer of btn "button1" to 66
set the layer of btn "button22 tp 67
set the layer of btn "button999" to 68
etc.
Code: Select all
set the layer of grp "all of my buttons" to top
As I said "move for-/backward" will only change the layer of the object and may then "mask" the underlying objects.CAsba wrote: ↑Tue Oct 18, 2022 10:12 amI found the 'menu option' in the object inspector menu, the four options were send to back, bring to front, move backward, move forward. I just tried it out, I placed one button 'on top of' another and clicked on the menu options 'bring forward' and 'send to back' and the buttons alternated in being visible.
Example:
You have two buttons "b1" and b2" and both have identical dimensions width/height and also identical LOCs.
If the layer of btn "b1" = 1 and layer of "b2" = 2 then "b1" will be UNDER "b2"
If the layer of btn "b2" = 1 and layer of "b1" = 2 then "b2" will be UNDER "b1"
Get it? Just like the "levels" in Photoshop or any other image editing application
Important hint for groups!
The global property "selectgroupedcontrols", in Menu: Edit: Select Grouped Controls, will make groups appear as ONE object.
If it is unchecked, when you select the group with the POINTER tool, the group will be treated as ONE object.
If CHECKED then you can select all objects in the group as individual objects.
Just try it out to get used to it!
Best
Klaus
Re: Move object forward/backward
Thank you Klaus, for your patience and your advice.
Re: Move object forward/backward
It is much simpler to show and hide the various groups instead of changing their layers. Why manage layers, especially if you have several?
Just think about this, an example with three groups, named "A", "B" and "C", each containing the buttons you want to show. A separate "control" button might have this in its script:
You never need to know anything about the layers. Every time you select a group, that one appears, and all the others go away.
Craig
Just think about this, an example with three groups, named "A", "B" and "C", each containing the buttons you want to show. A separate "control" button might have this in its script:
Code: Select all
on mouseUp
answer "Show which group?" with "A" or "B" or "C"
hide group "A"
hide group "B"
hide group "C"
show group it
end mouseUp
Craig
Re: Move object forward/backward
The only improvement to suggest is considering making this into a card-wide handler (eg in the card script) so it can be called in any number of ways. If I have groups (or buttons etc) I would give them names with a prefix that separates them from other groups so I can iterate through all the groups to hide all the relevant ones and then only show the intended group. In this case let’s say we call the groups showA, showB, showC:dunbarx wrote: ↑Tue Oct 18, 2022 2:21 pmCode: Select all
on mouseUp answer "Show which group?" with "A" or "B" or "C" hide group "A" hide group "B" hide group "C" show group it end mouseUp
Code: Select all
Command showGroup pGroupName
Repeat with x = 1 to the number of groups of this card
If the short name of group x of this card contains “show” then
hide group x of this card
end if
End repeat
Show group pGroupName
End showGroup
Code: Select all
ShowGroup “showA”
Re: Move object forward/backward
Stam.
We generally think alike.
CAsba.
I do not know how you intend to "navigate" between your several groups of buttons. You did early on mention a special button to do all the heavy lifting. Anyway, that is a user interface issue, can be done in many ways, and is really secondary to the main point here. So are you set on a method of presenting only the group of interest, and hiding the others?
Craig
We generally think alike.

CAsba.
I do not know how you intend to "navigate" between your several groups of buttons. You did early on mention a special button to do all the heavy lifting. Anyway, that is a user interface issue, can be done in many ways, and is really secondary to the main point here. So are you set on a method of presenting only the group of interest, and hiding the others?
Craig