Package totalcross.ui.dialog
Class InputBox
- java.lang.Object
-
- totalcross.ui.gfx.GfxSurface
-
- totalcross.ui.Control
-
- totalcross.ui.Container
-
- totalcross.ui.Window
-
- totalcross.ui.dialog.InputBox
-
public class InputBox extends Window
This class pops up a Window with a Label, an Edit and some buttons. Good to input some text from the user. Here is an example (taken from examples/apps/GuiBuilder):// on some event... if (renameDialog == null) renameDialog = new InputBox("Project Rename","Please enter the new name which will be used for the project:",""); renameDialog.setValue(projectName); renameDialog.popup(); // when window closes... if (renameDialog.getPressedButtonIndex() == 0) // ok? { projectName = renameDialog.getValue(); }
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class totalcross.ui.Control
Control.TranslucentShape
-
-
Field Summary
Fields Modifier and Type Field Description int[]buttonKeysIf you set the buttonCaptions array in the construction, you can also set this public field to an int array of the keys that maps to each of the buttons.static booleanopenKeyboardOnPopupSet to true to automatically open the keyboard once the InputBox is open.intyPositionDefines the y position on screen where this window opens.-
Fields inherited from class totalcross.ui.Window
_controlEvent, _dragEvent, _focus, _keyEvent, _mouseEvent, _multiEvent, _penEvent, androidBorderThickness, beepIfOut, blocking, borderStyle, cancelPenUp, canDrag, dragThreshold, fadeOtherWindows, fadeValue, firstFocus, flickEnabled, focusOnPenUp, footerColor, footerH, gradientTitleEndColor, gradientTitleStartColor, headerColor, highlighted, highResPrepared, HORIZONTAL_GRADIENT, ignoreEventOfType, keyHook, lastShiftY, lastSwappedContainer, mainSwapContainer, menubar, multiTouching, needsPaint, NO_BORDER, ORIENTATION_INVERTED, ORIENTATION_LANDSCAPE, ORIENTATION_PORTRAIT, popped, RECT_BORDER, repaintOnSwap, robot, ROUND_BORDER, rTitle, sameBackgroundColor, shiftH, shiftY, SIP_BOTTOM, SIP_HIDE, SIP_SHOW, SIP_TOP, TAB_BORDER, TAB_ONLY_BORDER, tempTitle, title, titleAlign, titleColor, titleFont, titleGap, topMost, VERTICAL_GRADIENT, zStack
-
Fields inherited from class totalcross.ui.Container
alwaysEraseBackground, BACKGROUND_CYLINDRIC_SHADED, BACKGROUND_SHADED, BACKGROUND_SHADED_INV, BACKGROUND_SOLID, backgroundStyle, BORDER_LOWERED, BORDER_NONE, BORDER_RAISED, BORDER_ROUNDED, BORDER_SIMPLE, BORDER_TOP, borderColor, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastH, lastScreenWidth, lastW, npback, numChildren, started, tabOrder, tail, TRANSITION_CLOSE, TRANSITION_FADE, TRANSITION_NONE, TRANSITION_OPEN, TRANSITION_TIME, transitionEffect
-
Fields inherited from class totalcross.ui.Control
AFTER, alphaValue, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, BRIGHTER_BACKGROUND, callListenersOnAllTargets, CENTER, CENTER_OF, clearValueInt, clearValueStr, DARKER_BACKGROUND, DP, effect, enableUpdateScreen, esce, eventsEnabled, FILL, fillColor, FIT, floating, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, FONTSIZE, foreColor, height, ignoreInsets, isHighlighting, isTablet, KEEP, keepDisabled, keepEnabled, LEFT, next, nextTabControl, npParts, offscreen, offscreen0, onEventFirst, parent, PARENTSIZE, PARENTSIZEMAX, PARENTSIZEMIN, PREFERRED, prev, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, SCREENSIZE, SCREENSIZEMAX, SCREENSIZEMIN, setFont, setH, setRel, setW, setX, SETX_NOT_SET, setY, tempW, textShadowColor, TOP, translucentShape, transparentBackground, uiAdjustmentsBasedOnFontHeightIsSupported, uiAndroid, UICONST, uiFlat, uiHolo, uiMaterial, uiVista, visible, width, WILL_RESIZE, x, y
-
-
Constructor Summary
Constructors Constructor Description InputBox(java.lang.String title, java.lang.String text, java.lang.String defaultValue)Creates a new InputBox with the given window Title, the given label Text, the given Default value for the Edit, and two buttons "Ok" and "Cancel".InputBox(java.lang.String title, java.lang.String text, java.lang.String defaultValue, java.lang.String[] buttonCaptions)Creates a new InputBox with the given window Title, the given label Text, the given Default value for the Edit and with the given buttons.InputBox(java.lang.String title, java.lang.String text, java.lang.String defaultValue, java.lang.String[] buttonCaptions, boolean allSameWidth, int gap, int insideGap)Creates a new InputBox with the given window Title, the given label Text, the given Default value for the Edit and with the given buttons.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EditgetEdit()Returns the Edit so you can set its properties.intgetPressedButtonIndex()Returns the pressed button index, starting from 0java.lang.StringgetValue()Returns the value enteredvoidonEvent(Event e)handle scroll buttons and normal buttonsprotected voidonPopup()Placeholder called imediatly before the popup began.protected voidpostPopup()Placeholder called after the popup is done and after the repaint of this window.protected voidpostUnpop()Placeholder called after the unpop is done and after the repaint of the other window.voidreposition()Reposition this control, calling again setRect with the original parameters.voidsetEdit(Edit ed)Sets the Edit to the given one.voidsetTextAlignment(int align)Sets the alignment for the text.voidsetValue(java.lang.String value)Sets the default value on the Edit field-
Methods inherited from class totalcross.ui.Window
_doPaint, _postEvent, destroyZStack, drawHighlight, fillBackground, getBorderStyle, getClientRect, getClientRect, getDefaultDragThreshold, getFocus, getHighlighted, getPopupCount, getPreferredHeight, getPreferredWidth, getSafeAreaInsets, getTitleFont, getTopMost, handleFocusChangeKeys, isScreenShifted, isSipShown, isSipShown4D, isTopMost, isVisible, loadBehind, makeUnmovable, onClickedOutside, onRobotKey, onUnpop, paintTitle, paintWindowBackground, popup, popupMenuBar, popupNonBlocking, postPressedEvent, pumpEvents, removeFocus, repaintActiveWindows, resize, resizeHeight, resizeWidth, screenResized, setBorderStyle, setDeviceTitle, setFocus, setGrabPenEvents, setHighlighted, setMenuBar, setOrientation, setSIP, setTitle, setTitleFont, shiftScreen, swap, swapFocus, unpop, validate
-
Methods inherited from class totalcross.ui.Container
add, add, add, add, add, applyTransitionEffect, broadcastEvent, clear, findChild, findNearestChild, findNextFocusControl, getChildren, getChildrenCount, getFirstChild, getFocusableControls, getInsets, incLastX, incLastY, initUI, isPressed, moveFocusToNextControl, moveFocusToNextEditable, onAddAgain, onColorsChanged, onPaint, onRemove, onSwapFinished, paintChildren, remove, removeAll, setEnabled, setFocusTraversable, setHighlighting, setInsets, setNextTransitionEffect, setPressColor, setPressed, swapToTopmostWindow
-
Methods inherited from class totalcross.ui.Control
_onEvent, addEnabledStateListener, addFocusListener, addFontChangeHandler, addGridListener, addHandler, addHighlightListener, addKeyListener, addListContainerListener, addMouseListener, addMultiTouchListener, addPenListener, addPressListener, addPushNotificationListener, addSizeChangeHandler, addTimer, addTimer, addTimerListener, addValueChangeHandler, addWindowListener, bringToFront, changeHighlighted, contains, drawTranslucentBackground, getAbsoluteRect, getBackColor, getDoEffect, getEffectH, getEffectW, getEffectX, getEffectY, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getTextShadowColor, getWidth, getX, getX2, getY, getY2, hadParentScrolled, handleGeographicalFocusChangeKeys, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isFloating, isInsideOrNear, isObscured, isVisibleAndInside, onBoundsChanged, onFontChanged, onWindowPaintFinished, post, postEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHandler, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, repositionChildren, requestFocus, resetSetPositions, resetStyle, safeRepaintNow, safeUpdateScreen, sendToBack, setBackColor, setBackForeColors, setDoEffect, setFloating, setFocusLess, setFont, setForeColor, setNinePatch, setNinePatch, setRect, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboard
-
-
-
-
Field Detail
-
openKeyboardOnPopup
public static boolean openKeyboardOnPopup
Set to true to automatically open the keyboard once the InputBox is open.- Since:
- TotalCross 1.53
-
yPosition
public int yPosition
Defines the y position on screen where this window opens. Can be changed to TOP or BOTTOM. Defaults to CENTER.- See Also:
Control.CENTER,Control.TOP,Control.BOTTOM
-
buttonKeys
public int[] buttonKeys
If you set the buttonCaptions array in the construction, you can also set this public field to an int array of the keys that maps to each of the buttons. For example, if you set the buttons to {"Ok","Cancel"}, you can map the enter key for the Ok button and the escape key for the Cancel button by assigning:buttonKeys = new int[]{SpecialKeys.ENTER,SpecialKeys.ESCAPE};Note that if you use the default Ok/Cancel buttons, this mapping is already done.- Since:
- TotalCross 1.27
-
-
Constructor Detail
-
InputBox
public InputBox(java.lang.String title, java.lang.String text, java.lang.String defaultValue)Creates a new InputBox with the given window Title, the given label Text, the given Default value for the Edit, and two buttons "Ok" and "Cancel". The text used in a Label can be multi-line. If the text is too big, it will be splitted.
-
InputBox
public InputBox(java.lang.String title, java.lang.String text, java.lang.String defaultValue, java.lang.String[] buttonCaptions)Creates a new InputBox with the given window Title, the given label Text, the given Default value for the Edit and with the given buttons. The text used in a Label can be multi-line. If the text is too big, it will be splitted.
-
InputBox
public InputBox(java.lang.String title, java.lang.String text, java.lang.String defaultValue, java.lang.String[] buttonCaptions, boolean allSameWidth, int gap, int insideGap)Creates a new InputBox with the given window Title, the given label Text, the given Default value for the Edit and with the given buttons. The text used in a Label can be multi-line. If the text is too big, it will be splitted.
-
-
Method Detail
-
onPopup
protected void onPopup()
Description copied from class:WindowPlaceholder called imediatly before the popup began. The default implementation does nothing.
-
setTextAlignment
public void setTextAlignment(int align)
Sets the alignment for the text. Must be CENTER (default), LEFT or RIGHT
-
reposition
public void reposition()
Description copied from class:ControlReposition this control, calling again setRect with the original parameters.- Overrides:
repositionin classControl
-
postPopup
protected void postPopup()
Description copied from class:WindowPlaceholder called after the popup is done and after the repaint of this window. The default implementation does nothing.
-
postUnpop
protected void postUnpop()
Description copied from class:WindowPlaceholder called after the unpop is done and after the repaint of the other window. The default implementation does nothing.
-
onEvent
public void onEvent(Event e)
handle scroll buttons and normal buttons
-
getPressedButtonIndex
public int getPressedButtonIndex()
Returns the pressed button index, starting from 0
-
getValue
public java.lang.String getValue()
Returns the value entered
-
setValue
public void setValue(java.lang.String value)
Sets the default value on the Edit field
-
getEdit
public Edit getEdit()
Returns the Edit so you can set its properties.
-
setEdit
public void setEdit(Edit ed)
Sets the Edit to the given one.
-
-