Page 1 of 2
Best way to slide stack into view
Posted: Fri Jun 24, 2011 4:19 am
by jesse
I am trying to create a menu that will be permanently docked on the left side of the screen. Thanks to some help I am understanding how to do this
but now I am trying to figure out the best method for displaying the stack in a smooth manner.
I want to slide the stack into view. It will start out just wide enough so the user knows its a menu box basically. then the user
clicks on a logo on the stack and the menu will slide out. this is the code i am in the mouseup right now but am sure there is
probably a better way.
Code: Select all
repeat for 40 times
set the width of this stack to the width of this stack + 10
wait 5
end repeat
edit: i know my code is not the best because wait locks up the whole application. there must be a better way.
Re: Best way to slide stack into view
Posted: Fri Jun 24, 2011 5:27 am
by dglass
That Panel example I provided in the Summer Academy forum would be a good place to start.

Re: Best way to slide stack into view
Posted: Fri Jun 24, 2011 5:42 am
by jesse
You mean the panel splitter example? I see that let's
Me resize panels but I'm not sure how to show
And hide a stack into or out of view.
Re: Best way to slide stack into view
Posted: Fri Jun 24, 2011 5:45 am
by dglass
No, I mean the example I put together to show you how to mimic a drawer.
Re: Best way to slide stack into view
Posted: Fri Jun 24, 2011 6:13 am
by jesse
got it. only problem is that wait locks the screen up. is there any other way to do with out locking up the screen during the sliding of the stack out?
Re: Best way to slide stack into view
Posted: Fri Jun 24, 2011 6:24 am
by dglass
put a 'with messages' at the end of the 'wait' call.
I commented that bit out in the example stack, so it's there ... waiting.
Re: Best way to slide stack into view
Posted: Fri Jun 24, 2011 6:49 am
by jesse
Thanks. One more question I got it working using the below code in stack code
For hidePanel I would like to give the user a grace period before the menu panel
hides. Basically if the user re-enters the panel with their mouse before 20 miliseconds it should keep from running hidePanel. Any idea how to do that?
BTW: Does my code seem to make sense did i do everything correctly.
What happens is there is always 30 pixels wide of the panel showing when the mouse click in the panel it slides out. when the mouse leaves
the panel it slides in basically sliding the panel off screen and leaving just 30 pixels.
Code: Select all
on mouseleave
hidePanel
end mouseleave
on mousedown
showPanel
end mousedown
on hidePanel
repeat while the left of this stack > -150
lock screen
set the left of this stack to the left of this stack - 1
go to this stack
unlock screen
wait 10 milliseconds with messages
end repeat
end hidePanel
on showPanel
set the width of this stack to 180
set the height of this stack to item 4 of the screenrect - item 2 of the screenrect
set the left of this stack to -165
set the top of this stack to 0
repeat while the left of this stack < 0
lock screen
set the left of this stack to the left of this stack + 1
go to this stack
unlock screen
wait 10 milliseconds with messages
end repeat
end showPanel
Re: Best way to slide stack into view
Posted: Fri Jun 24, 2011 7:00 am
by dglass
You probably don't need the 'go to this stack' calls. I had that in the drawer example in an attempt to keep the parent stack in front of the 'drawer' stack.
I would try something like...
Code: Select all
on mouseleave
put true into sExitingMenu
send "hidePanel" to me in 20 milliseconds
end mouseleave
on hidePanel
if sExitingMenu is true then
...do stuff to hide the stack
end if
end hidePanel
on mouseEnter
put false into sExitingMenu
...other stuff
end mouseEnter
Re: Best way to slide stack into view
Posted: Fri Jun 24, 2011 4:26 pm
by jesse
works great. i got that all set up just one problem i cant seem to figure out. When I mouseenter the stack it calls my showPanel command,
and when i mouseleave it calls hidePanel but if i hover my mouse back oveer the stack before 2 seconds it doesn't stop the hidepanel it still
hides the panel. What do I need to do to make it stop performing hidePanel and go back to showPanel. I thought checking the mousestack
against the shortname would work but it didnt. any ideas?
this my stack code:
Code: Select all
on preopenstack
set the width of this stack to 170
set the height of this stack to item 4 of the screenrect - item 2 of the screenrect
set the left of this stack to -155
set the top of this stack to 0
end preopenstack
global sExitingmenu
on mouseleave
put true into sExitingmenu
if the mousestack is not the short name of me then
send "hidePanel" to me in 2000 milliseconds
end if
end mouseleave
on mouseenter
if the mousestack is the short name of me then
showPanel
end if
end mouseenter
on hidePanel
answer "should hide"
answer sExitingmenu
if sExitingmenu is true then
repeat while the left of this stack > -150
lock screen
set the left of this stack to the left of this stack - 1
go to this stack
unlock screen
wait 5 milliseconds with messages
end repeat
end if
end hidePanel
on showPanel
repeat while the left of this stack < 0
lock screen
set the left of this stack to the left of this stack + 1
go to this stack
unlock screen
wait 5 milliseconds with messages
end repeat
end showPanel
Re: Best way to slide stack into view
Posted: Fri Jun 24, 2011 4:30 pm
by dglass
In your 'mouseenter' handler you aren't setting sExitingMenu to false. If you add that what happens?
Re: Best way to slide stack into view
Posted: Fri Jun 24, 2011 4:57 pm
by jesse
It seems like that feature is "sticky". If I mouse over the stack it shows the slide. If I mouse out and then back in
the slide doesn't go away but if i mouse out again its confused by that point i guess and doesn't do anything unless i
mouse click on the stack. I have attached the source file and also added a field status that shows enter, and leaving
the the stack to see that it does not work sometimes. is this just the way things work or is there a fix?
Re: Best way to slide stack into view
Posted: Fri Jun 24, 2011 5:40 pm
by dglass
The attached seems to do what you want.
a) because you have mouse handlers in your card script you need to 'pass' them along if you have them in any of the objects on that card.
b) I added a check of sExitingMenu within the hiding loop in case the value changes while it is hiding.
c) I added setting the sExitingMenu in the mousemove if the mousestack is the right stack. This should ensure the value is always correct.
Re: Best way to slide stack into view
Posted: Fri Jun 24, 2011 8:29 pm
by jesse
Brilliant. Exactly what I needed. Thank you so much. I see how it works now and why it wasn't working completely for me.

Re: Best way to slide stack into view
Posted: Fri May 29, 2015 8:26 pm
by catalinanesia
Uau,
Thanks for this share, I do have a strange or not behavior with this ...
I opened the stack in LiveCode Comunity V6.6.2 under Windows XP,
the LC is in EDIT mode and the stack it is nicely positioned on the left side of the screen
almost hidden and with the mouse over it is nicely and smoothly sliding on the screen
and when i click of the stack it slides back, uau but: LC is in Edit mode so how come the stack is active?
if this is a feature of LC then sorry for my lack of knowledge ... (is it the preopenCard handler who does that?)
when I switch LC in RUN mode the movement it is very very lagging (it is not smooth anymore)
Nice stack any way!
Thanks to the creator.
Catalin
Re: Best way to slide stack into view
Posted: Fri May 29, 2015 9:26 pm
by Simon
Hi Catalin,
Look at the changes here;
Code: Select all
on showPanel
--repeat while the left of this stack < 0
if the left of this stack <0 then
lock screen
set the left of this stack to the left of this stack + 5
unlock screen
--wait 5 milliseconds with messages
--end repeat
send "showPanel" to me in 25 millisecs
end if
end showPanel
That send in time works much better.
Simon