Page 1 of 2
Using a button to temporarily reveal a container
Posted: 21 Dec 2012 10:06
by XRM5
I'd like to have a container holding several buttons appear and fill the screen when I push a custom button object, then vanish the first time I press any one of the buttons contained in it.
Am I headed in the right direction experimenting with the show script? Thus far I haven't been able to make it work.
Once I've gotten that script to work, then to hide the container again I guess I just need a script that watches all of the container's buttons for a change of state? Would that be an if/else thing?
Thanks.
Re: Using a button to temporarily reveal a container
Posted: 21 Dec 2012 10:57
by Softcore
The most easy way I can think of is
create an expression (no need to be a script), name it for example k, inside your initial button (switch mode)
This will show the container when the button is pressed and also hide it if its pressed again.
Now for the buttons inside the container one could think of:
BUT what I really dont know is this detail: the moment you press the button INSIDE the container and it goes hidden we have a small technical problem - when you pressed the button you created a "cursor". Then the container hides, so I dont really know what happens with that created cursor - is it still assumed to be there? I think it is! And I also think, even hidden, that button has stayed "pressed". Will it cause any memory leaks/problems? Will turning capture mode off for those buttons be sufficient to make sure that the cursor is "destroyed" when the container is hidden? For these above reasons I avoid using objects which hide containers INSIDE these containers - Id prefer using the "outside" initial button just to be on the safe side.
P.S. : Of course if it is crucial to your project that the container closes after pressing the "inside" buttons you can:
create a script in each inside button on expression x dropping to 0 (change the "any" to down arrow)
this assures that the container is hidden AFTER the destruction of the cursor
and inside the script
In essense, this will hide the container not when any button inside the container is pressed, BUT when it is released. If we are talking about switch buttons however, we return to the "any" situation and the problems I describe in the first scenario. I think though turning capture mode off will be sufficient.
Re: Using a button to temporarily reveal a container
Posted: 21 Dec 2012 15:45
by XRM5
Thanks for such a fast & detailed answer, Softcore!
The script to show the container works great, and I agree with you that the best way to hide the container would be after the inside control is released. An upside to that is that I might be able to include a fader with my planned buttons that can also hide the container when it is released.
I'm still working through getting it to hide again though. I was a little confused by your wording: "create a script in each inside button on expression x dropping to 0."
Re: Using a button to temporarily reveal a container
Posted: 21 Dec 2012 16:19
by Traxus
In the right hand column, where you see all of your objects listed. Click on each button (alternately, you can click on the button on the screen) to select it. Once you have a button selected, click SCRIPT in the bottom right corner, it will ask you to name it, call it hideContainer().
Once you have named it, you'll see the editor pad become active near the bottom of the screen, above the area where you'd enter the code, there is a drop down menu called execution, its default will be 'manual', change this to 'on expression' and then in the box to the right of this drop down type x. Then paste the code he gave you in the editor area below. Do this for each of the buttons in the container.
Re: Using a button to temporarily reveal a container
Posted: 21 Dec 2012 16:27
by XRM5
So far it's just contradicting the button that reveals the container & leaves it hidden, or the container only goes away momentarily when I interact with the button then returns.
EDIT: just saw that new reply, must have gone up while I was typing. Trying now. Thanks!
Re: Using a button to temporarily reveal a container
Posted: 21 Dec 2012 17:24
by XRM5
That did the trick, Traxus--I'm almost there now. Everything's working as it should, except that the container is not disappearing when I release the button, it's disappearing when I first touch it.
I'm using a custom button, pad behavior, capture off. I set the velocity to the down arrow & my script is set to "execute on expression" with x in the blank.
To get the script out of the red, I had to add a semicolon @ the end, so my script is:
show(container, 0);
I must be missing a step to get the Lemur to skip the original press and wait for the release. I'm excited to figure this out because I imagine once I've got it I can link a similar script to the z variable of a fader & get the container to disappear when I release the fader too.
Thanks for all this help.
Re: Using a button to temporarily reveal a container
Posted: 23 Dec 2012 12:01
by Softcore
In script window, there are some selectable settings, execution, then the expression (in our case the x) and then the criteria of when the expression (x) does what.....by default this is set to "any" (look for that "any" setting in your script window).
Clikcing on it reveals other settings like "when x rises from 0" symbolized by an up arrow or "when x drops to 0" symbolized by a down-arrow. When unsure, select a setting and then hover your mouse over it to see what it does (tip appears).
By saying "set on Expression x when drops to 0 I meant:
Now these settings come in very handy because, for example you dont have to use a lot o f"ifs" in your scripts - the "if (x==0)" for example can be completly replaced with an expression x set like in the image!
And yes you are right in thinking that by replacing the above "x" (in the image) with "z" inside a fader, the container will hide as soon as you release the fader.
Re: Using a button to temporarily reveal a container
Posted: 23 Dec 2012 12:41
by XRM5
The picture cleared it up--the dropdown is kinda lurking over there. I had thought you were referring to the one in the Mapping window.
Everything's working perfectly now! Thanks again.
Re: Using a button to temporarily reveal a container
Posted: 23 Dec 2012 12:51
by Softcore
yeah saw the velocity mentioned and figured!
better change that back to its default "any"
As for the semicolons, sorry forgot to type those in my code windows above but yeah,a s you figured, each line must end with ;
Re: Using a button to temporarily reveal a container
Posted: 18 Mar 2013 00:04
by mssngmrblz
any chances you could share this ????