Move object forward/backward

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9664
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Move object forward/backward

Post by dunbarx » Tue Oct 18, 2022 6:58 pm

CAsba.

Stam makes a point. Lock the screen so you do not see any of this hiding and showing. With such a small amount of activity, you might not notice anything, but certainly this is good practice with this sort of shenanigans, and would likely be really necessary with large numbers of controls doing possibly large amounts of moving around.

Locking the screen does just that, hiding all activity going on under script control. The screen automatically unlocks when the handler ends, leaving you with only the resultant state.

Craig

CAsba
Posts: 364
Joined: Fri Sep 30, 2022 12:11 pm

Re: Move object forward/backward

Post by CAsba » Wed Oct 19, 2022 10:22 am

Hi Craig,
It's now working fine, and I didn't group the buttons, I just did this:-
on mouseUp pMouseButton
if field moresales = "xx" then
set the layer of button "print a quotation" to top
set the layer of button "Manage products" to top
put "yy" into field moresales
exit mouseup
end if
if field moresales = "yy" then
set the layer of button "view current debtorss" to top
set the layer of button "Raise a proforma invoice" to top

put "xx" into field moresales
end if
end mouseUp
Yes, I will add an initial line of lockscreen
Thanks.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Move object forward/backward

Post by Klaus » Wed Oct 19, 2022 11:46 am

Hi CAsba,

please dd the CODE tags above -> <> after pasting your script here.
This way the formatting will be preserved, see below.

Code: Select all

on mouseUp pMouseButton
   beep
end mouseUp
And in your own interest please ALWAYS use quotes around object names:

Code: Select all

## field moresales
...fld "moresales"
Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9664
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Move object forward/backward

Post by dunbarx » Wed Oct 19, 2022 3:25 pm

CAsba.

Always good to have a solution.

But do you see why I am promoting the idea of hiding the unwanted controls instead of "buryIng" them under others? In my mind, especially if you will ever have more than just two levels, layering will become unmanageable. And what happens if you ever need to actually place certain controls in specific layers, or to switch layers among others? You have to "reserve" specific layer values for this particular functionality. It is really not the right way to do it.

Something to consider as you learn more LiveCode is to try to make your efforts robust. That means that they are built in such a way that allows flexibility in the future. Hiding has none of the baggage that layering does. There is no "hierarchy" when you hide or show. All hidden controls are just that, hidden. And all visible controls are just that, visible. This cuts through the traps inherent in putting one thing on top of another. Hide/Show does not matter how many controls are in play or whether you add or subtract controls as you develop.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9664
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Move object forward/backward

Post by dunbarx » Wed Oct 19, 2022 3:26 pm

Jacque. Just don't.

CAsba. For homework, change your current effort to a Hide/Show one. There will be a test later. :wink:

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Move object forward/backward

Post by jacque » Thu Oct 20, 2022 6:22 pm

dunbarx wrote:
Wed Oct 19, 2022 3:26 pm
Jacque. Just don't.
Heh. I've given up on you Craig, you're incorrigible. :D
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”