Skip to content

Commit

Permalink
TestMultipleScreens: test changing screens from within a popup menu
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Apr 12, 2017
1 parent 9fd7fc8 commit 815e4aa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import jme3utilities.MyString;
import jme3utilities.nifty.BasicScreenController;
import jme3utilities.nifty.GuiApplication;
import jme3utilities.nifty.GuiScreenController;
import jme3utilities.ui.InputMode;

/**
Expand All @@ -56,7 +57,7 @@ public class TestMultipleScreens extends GuiApplication {
/**
* controller for screen s1: set in guiInitializeApplication()
*/
private BasicScreenController s1 = null;
private GuiScreenController s1 = null;
/**
* controller for screen s2: set in guiInitializeApplication()
*/
Expand Down Expand Up @@ -111,7 +112,7 @@ public void guiInitializeApplication() {
/*
* Create and attach a screen controller for each screen.
*/
s1 = new BasicScreenController("TestMultipleScreens/s1",
s1 = new GuiScreenController("TestMultipleScreens/s1",
"Interface/Nifty/screens/TestMultipleScreens/s1.xml", true);
s1.setListener(inputMode);
boolean success = stateManager.attach(s1);
Expand Down Expand Up @@ -154,6 +155,11 @@ public void onAction(String actionString, boolean ongoing, float ignored) {
old.setEnabled(false);
s3.setEnabled(true);
return;
case "open menu":
assert s1.isEnabled();
String[] items = {"s2", "s3"};
GuiScreenController.showPopup("go ", items);
return;
}
}
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
-->
<nifty xmlns="http://nifty-gui.lessvoid.com/nifty-gui">
<screen id="TestMultipleScreens/s1"
controller="jme3utilities.nifty.BasicScreenController">
controller="jme3utilities.nifty.GuiScreenController">
<layer childLayout="vertical"
backgroundColor="#444f">
<panel/>
Expand All @@ -42,6 +42,12 @@
height="40px"
padding="10px">
<panel/>
<control name="button" id="id90ToAvoidOffendingNifty"
label="open menu"
width="100px">
<interact onRelease="perform(open menu)"/>
</control>
<panel/>
<control name="button" id="id91ToAvoidOffendingNifty"
label="go to s2"
width="100px">
Expand Down

0 comments on commit 815e4aa

Please sign in to comment.