public class PopupMenu extends Window
String[] items = { "Always", "Never", "Only in Silent mode", "Only when not in Silent mode", "Non of the answers above", }; PopupMenu pm = new PopupMenu("Vibrate", items); pm.popup();A PRESSED event is sent when an item is selected. Note: the colors must be set before the control's bounds are defined using setRect or add.
Control.TranslucentShape
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
cancelString
The string of the button; defaults to "Cancel"
|
int |
checkColor
The check color used to fill the radio button used in Android.
|
int |
dataCol
If the items is a String matrix (String[][]), this field sets the column that
will be shown.
|
boolean |
enableCancel
Set to false BEFORE popping up the window to disable the Cancel button.
|
boolean |
enableSearch
Set to true BEFORE popping up the window to enable search on the items of
this PopupMenu.
|
int |
itemCount
Sets the number of elements should be used from the items array passed in the
constructor.
|
boolean |
keepIndexOnCancel
Set to true to keep the selected index unchanged if user press the Cancel
button
|
_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
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, borderRadius, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastH, lastScreenWidth, lastW, numChildren, started, tabOrder, tail, TRANSITION_TIME
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 and Description |
---|
PopupMenu(java.lang.String caption,
java.lang.Object[] items)
Constructs a PopupMenu with the given parameters and without multiple
selection support.
|
PopupMenu(java.lang.String caption,
java.lang.Object[] items,
boolean multipleSelection)
Constructs a PopupMenu with the given parameters.
|
Modifier and Type | Method and Description |
---|---|
ListBox |
getMenu()
Returns the ListBox used to show the menu.
|
int |
getPreferredHeight()
Returns the size of the title if any plus the size of the border.
|
int |
getPreferredWidth()
Returns the size of the title if any plus the size of the border.
|
int |
getSelectedIndex()
Returns the selected index when this window was closed or -1 if non was
selected
|
java.lang.Object |
getSelectedItem() |
void |
initUI()
Called to initialize the User Interface of this container.
|
boolean |
onClickedOutside(PenEvent event)
called when the user clicks outside the bounds of this window.
|
void |
onEvent(Event event)
Called to process key, pen, control and other posted events.
|
void |
onPaint(Graphics g)
Draws the border (if any).
|
protected void |
onPopup()
Setup some important variables
|
void |
popupAt(int x,
int y) |
void |
popupAt(int x,
int y,
int width,
int height) |
protected void |
postUnpop()
Placeholder called after the unpop is done and after the repaint of the other window.
|
void |
reposition()
Reposition this control, calling again setRect with the original parameters.
|
void |
setCursorColor(int c)
Sets the cursor color.
|
int |
setSelectedIndex(int index)
Selects the given index.
|
void |
setTitle(java.lang.String title)
Sets the title and call repaint.
|
_doPaint, _postEvent, destroyZStack, drawHighlight, getBorderStyle, getClientRect, getClientRect, getDefaultDragThreshold, getFocus, getHighlighted, getPopupCount, getTitleFont, getTopMost, handleFocusChangeKeys, isScreenShifted, isSipShown, isSipShown4D, isTopMost, isVisible, loadBehind, makeUnmovable, onRobotKey, onUnpop, paintTitle, paintWindowBackground, popup, popupMenuBar, popupNonBlocking, postPopup, postPressedEvent, pumpEvents, removeFocus, repaintActiveWindows, resize, resizeHeight, resizeWidth, screenResized, setBorderStyle, setDeviceTitle, setFocus, setGrabPenEvents, setHighlighted, setMenuBar, setOrientation, setSIP, setTitleFont, shiftScreen, swap, swapFocus, unpop, validate
add, add, add, add, add, broadcastEvent, clear, fillBackground, findChild, findNearestChild, findNextFocusControl, getBorderRadius, getChildren, getChildrenCount, getFirstChild, getFocusableControls, getInsets, incLastX, incLastY, isPressed, moveFocusToNextControl, moveFocusToNextEditable, onAddAgain, onColorsChanged, onRemove, onSwapFinished, paintChildren, remove, removeAll, setBorderRadius, setEnabled, setFocusTraversable, setHighlighting, setInsets, setPressColor, setPressed, swapToTopmostWindow
_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
public static java.lang.String cancelString
public int dataCol
public int itemCount
items.length
.public int checkColor
public boolean enableSearch
public boolean enableCancel
public boolean keepIndexOnCancel
public PopupMenu(java.lang.String caption, java.lang.Object[] items) throws IOException, ImageException
IOException
ImageException
public PopupMenu(java.lang.String caption, java.lang.Object[] items, boolean multipleSelection) throws IOException, ImageException
IOException
ImageException
public boolean onClickedOutside(PenEvent event)
Window
beepIfOut
is true, then a beep is played and nothing more happens.onClickedOutside
in class Window
public void initUI()
Container
public void reposition()
Control
reposition
in class Control
public void onEvent(Event event)
Control
public void onPaint(Graphics g)
Container
super.onPaint(g);
, or the border will not be drawn.public void setTitle(java.lang.String title)
Window
public int getPreferredWidth()
Window
getPreferredWidth
in class Window
public int getPreferredHeight()
Window
getPreferredHeight
in class Window
public ListBox getMenu()
public java.lang.Object getSelectedItem()
public int setSelectedIndex(int index)
public int getSelectedIndex()
public void popupAt(int x, int y, int width, int height)
public void popupAt(int x, int y)
protected void postUnpop()
Window
public void setCursorColor(int c)