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: 10502
Joined: Wed May 06, 2009 2:28 pm

Re: Move object forward/backward

Post by dunbarx »

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: 452
Joined: Fri Sep 30, 2022 12:11 pm

Re: Move object forward/backward

Post by CAsba »

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: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Move object forward/backward

Post by Klaus »

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: 10502
Joined: Wed May 06, 2009 2:28 pm

Re: Move object forward/backward

Post by dunbarx »

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: 10502
Joined: Wed May 06, 2009 2:28 pm

Re: Move object forward/backward

Post by dunbarx »

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: 7423
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Move object forward/backward

Post by jacque »

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