PDA

View Full Version : checking if a container is shown


Gonzotek
11th July 2002, 14:13
I had a discussion with Francis along these lines months ago. Here's the deal: Even though you can show(), hide(), and toggle() containers, they aren't guiobjects, and thus cannot use .isVisible, nor is there an onShowContainer nor onHideContainer, nor onToggle (although you can .toggle() it.).

What you can do, however, is get the total number of containers ( getNumContainers() ), then use a for loop to walk through them . Inside the for loop, do enumContainer(i), to get each container one at a time. Once you have the container in a temp object, you do tempcontainer.getNumLayouts, and start another for loop. Inside the second loop, you check each layout of the temp container to determine if it is visible or not.

If the container you're looking for exists, and if any layout of the container is visible, set an int to 1, and then you can exit the loops, check if the int is 1, and do your stuff. Not exactly easy, is it? In speaking to Francis about it, he explained that a container isn't a guiobject, and thus can't be seen, so I asked Francis: If I can show, hide, and toggle a container, then why can't I check it visibility, or use onShowContainer, etc? It just makes sense to be able to access that information in a simple way. I don't care if it's my shade mode, or main mode showing, I just want to know if the container is open or not, right?


If you're having trouble following my ramble, the code for it is already in QuarkAmp...I *think* the code for that should still be correct for the latest builds.
-=Gonzotek=-

mc^^^^
11th July 2002, 16:54
my way would be to show the container onscriptloaded, and at the same time set an int to 1, make a button in maki that hides the container, and at that same time changes the int to 0. understand?

Gonzotek
11th July 2002, 17:40
Originally posted by mc^^^^
my way would be to show the container onscriptloaded, and at the same time set an int to 1, make a button in maki that hides the container, and at that same time changes the int to 0. understand?

But that doesn't solve the problem:
is there a way in maki do do something only if the container is visible?

Setting the int in onscriptloaded doesn't help us to know when the user has opened or closed the container after the script is loaded.

-=Gonzotek=-

CremoNe
11th July 2002, 18:27
can't you add 1 to the int each time you toggle, so that you can chec if it's on or off by the parity?

mc^^^^
11th July 2002, 19:00
make a button in maki to show/hide the container depending on whether the int is 1 or 0


if (containervisible ==1) {
container.hide();
containervisible = 0;
}
else {
container.show();
containervisible = 1;
}


save and load the container's state into the studio.xnf, and run that onscriptloaded.

that way if you want something to happen only if the container is visible, you would do this:


if (containervisible ==1) {
//do shit
}


s-i-m-p-l-e

Gonzotek
11th July 2002, 19:04
It always comes back to not being able to attach get the hide/show/toggle events of containers. There is NO onShow, onHide, or OnToggle for containers, so there isn't an event to cause the int to increment. Like I explained in my first post, I asked Francis about it: I can show, hide and toggle containers, but I can't use onShow, onHide, and onToggle. Why not?

He said that he'd add the functionality, but that was when Winamp3 was still in alpha. Now we're at rc3(almost), and they still aren't in. Not that I'm bitching, but I think it's safe to assume that they won't be there before 3 final.

-=Gonzotek=-

Gonzotek
11th July 2002, 19:05
Originally posted by mc^^^^
make a button in maki to show/hide the container depending on whether the int is 1 or 0


if (containervisible ==1) {
container.hide();
containervisible = 0;
}
else {
container.show();
containervisible = 1;
}


save and load the container's state into the studio.xnf, and run that onscriptloaded.

that way if you want something to happen only if the container is visible, you would do this:


if (containervisible ==1) {
//do shit
}


s-i-m-p-l-e

And what happens when the user doesn't use the button, but uses the Windows menu? Not so simple.

-=Gonzotek=-

mc^^^^
11th July 2002, 19:11
you win :(