SpoutDev/Spout — Issue #695: How to Lock Escape a Popup with "Esc" Key
Author: TheCherry
Created: 2011-10-11 11:03:50+00:00
State: open

Hello,

i want write a Login Plugin with Spout, its my first Spout Project and should be a exercise.
I want that the user can use the loginbutton + textfield for login, else he can press the Exit button for Disconnect.
But how i can lock the "Esc" Key? I try it with this :

Main :
getServer().getPluginManager().registerEvent(Event.Type.CUSTOM_EVENT, new myInputListener(this), Event.Priority.Lowest, this); (Highest or Normal don't work too)

myInputListener :
public void onKeyPressedEvent(KeyPressedEvent event) {
if(plugin.menuOpen && event.getKey() == Keyboard.KEY_ESCAPE){
event.getPlayer().closeActiveWindow();
event.getPlayer().getMainScreen().closePopup();
//event.getPlayer().getMainScreen().getActivePopup().close();
doGUI(event.getPlayer());
}
}
@SuppressWarnings("unused")
private void doGUI(SpoutPlayer pl){
GenericPopup somepopup = new GenericPopup();
GenericLabel label = new GenericLabel("This is a label");
somepopup.attachWidget(label);
pl.getMainScreen().attachWidget(label);

GenericButton button = new GenericButton("Buttontext");
button.setX(100).setY(100); //Puts the button at 100*100 on the screen
button.setWidth(200).setHeight(20); //Makes the button 200 wide and 20 high
somepopup.attachWidget(button); //This is necessary because you need a mouse to interact with a button.
pl.getMainScreen().attachPopupScreen(somepopup);
plugin.menuOpen = true;
}

Then i press Esc it close the popup and nothing more. Then i press again esc its open the normal gamemenu, its quit and open my gui. Same try with onScreenClose() from ScreenListener, same result.