#27 expose messagebox type for inputbox
[nikiroo-utils.git] / src / jexer / demos / DemoMsgBoxWindow.java
index a56da43760e3b38176f90e4dc33d034530b70d4a..b6c9404f74f9e1b02a07cc17e0fbb8bf23e04f9f 100644 (file)
@@ -3,7 +3,7 @@
  *
  * The MIT License (MIT)
  *
- * Copyright (C) 2016 Kevin Lamonte
+ * Copyright (C) 2017 Kevin Lamonte
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
 package jexer.demos;
 
 import jexer.*;
+import static jexer.TCommand.*;
+import static jexer.TKeypress.*;
 
 /**
  * This window demonstates the TMessageBox and TInputBox widgets.
  */
 public class DemoMsgBoxWindow extends TWindow {
 
+    // ------------------------------------------------------------------------
+    // Constructors -----------------------------------------------------------
+    // ------------------------------------------------------------------------
+
     /**
      * Constructor.
      *
@@ -53,7 +59,7 @@ public class DemoMsgBoxWindow extends TWindow {
     DemoMsgBoxWindow(final TApplication parent, final int flags) {
         // Construct a demo window.  X and Y don't matter because it
         // will be centered on screen.
-        super(parent, "Message Boxes", 0, 0, 60, 15, flags);
+        super(parent, "Message Boxes", 0, 0, 64, 18, flags);
 
         int row = 1;
 
@@ -131,7 +137,7 @@ public class DemoMsgBoxWindow extends TWindow {
         );
         row += 2;
 
-        addLabel("Input box", 1, row);
+        addLabel("Input box 1", 1, row);
         addButton("Open &input box", 35, row,
             new TAction() {
                 public void DO() {
@@ -146,6 +152,24 @@ public class DemoMsgBoxWindow extends TWindow {
                 }
             }
         );
+        row += 2;
+
+        addLabel("Input box 2", 1, row);
+        addButton("Cance&llable input box", 35, row,
+            new TAction() {
+                public void DO() {
+                    TInputBox in = getApplication().inputBox("Input Box",
+"This is an example of an InputBox.\n" +
+"\n" +
+"Note that the InputBox text can span multiple\n" +
+"lines.\n" +
+"This one has both OK and Cancel buttons.\n",
+                        "some input text", TInputBox.Type.OKCANCEL);
+                    getApplication().messageBox("Your InputBox Answer",
+                        "You entered: " + in.getText());
+                }
+            }
+        );
 
         addButton("&Close Window", (getWidth() - 14) / 2, getHeight() - 4,
             new TAction() {
@@ -154,6 +178,11 @@ public class DemoMsgBoxWindow extends TWindow {
                 }
             }
         );
+
+        statusBar = newStatusBar("Message boxes");
+        statusBar.addShortcutKeypress(kbF1, cmHelp, "Help");
+        statusBar.addShortcutKeypress(kbF2, cmShell, "Shell");
+        statusBar.addShortcutKeypress(kbF3, cmOpen, "Open");
+        statusBar.addShortcutKeypress(kbF10, cmExit, "Exit");
     }
 }
-