Page 2 of 2

Re: Move object forward/backward

Posted: Tue Oct 18, 2022 6:58 pm
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

Re: Move object forward/backward

Posted: Wed Oct 19, 2022 10:22 am
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.

Re: Move object forward/backward

Posted: Wed Oct 19, 2022 11:46 am
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

Re: Move object forward/backward

Posted: Wed Oct 19, 2022 3:25 pm
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

Re: Move object forward/backward

Posted: Wed Oct 19, 2022 3:26 pm
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

Re: Move object forward/backward

Posted: Thu Oct 20, 2022 6:22 pm
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