Disabled gui elements block mouse events?
Posted: Mon Jun 13, 2011 3:25 am
I'm making a main menu for my game.
I have a bunch of screen, each a separate object.
I create them all during a loading screen at the start and then when I want a particular screen to appear I call a function on it that enables all its gui elements and they are then drawn.
Screens not current displayed have all their elements disabled and are not drawn.
The problem with this approach is that only the elements closest to the front are catching mouse clicks.
Other screens that are further back aren't getting input because there are other (disabled and invisible) elements in front of them.
I had thought that disabling an element would stop it processing input but apparently not.
I don't really want to create and destroy the elements as the screens are shown because some use large textures and involve a lot of setup and there is a noticeable delay when they are created which is why I'm creating them all up front behind a loading screen.
I guess I could just shift all the disabled elements off screen and bring them back when the screen is shown but this feels like a hack.
Is there a better way to do this?
I have a bunch of screen, each a separate object.
I create them all during a loading screen at the start and then when I want a particular screen to appear I call a function on it that enables all its gui elements and they are then drawn.
Screens not current displayed have all their elements disabled and are not drawn.
The problem with this approach is that only the elements closest to the front are catching mouse clicks.
Other screens that are further back aren't getting input because there are other (disabled and invisible) elements in front of them.
I had thought that disabling an element would stop it processing input but apparently not.
I don't really want to create and destroy the elements as the screens are shown because some use large textures and involve a lot of setup and there is a noticeable delay when they are created which is why I'm creating them all up front behind a loading screen.
I guess I could just shift all the disabled elements off screen and bring them back when the screen is shown but this feels like a hack.
Is there a better way to do this?