public class Dropdown extends com.google.gwt.user.client.ui.Composite implements IMenuCombo
MenuCombo
that has the ability to store the selected item. When
Dropdown
is initially setup, the first enabled item is set to be the
selected item by default.Constructor and Description |
---|
Dropdown()
Setup a default dropdown with a raised action
Button and a menu
anchored to the bottom-left of the action button. |
Modifier and Type | Method and Description |
---|---|
void |
addItem(String item)
Has the same effect as Dropdown.addItem(item , true).
|
void |
addItem(String item,
boolean enabled)
Syntactic sugar for
IMenu.addItem(String, String, boolean) where
the text and value are the same. |
void |
addItem(String text,
String value)
Shortcut for
addItem(String, boolean) that adds an enabled
item to the menu. |
void |
addItem(String text,
String value,
boolean enabled)
Adds a new option to the list of options in the menu.
|
void |
addItem(String text,
String value,
int index,
boolean enabled)
Adds a an option into the set of options of the menu at a specified
position.
|
void |
addItemClickListener(Menu.ItemClickListener listener)
When an object needs to be notified upon a
MenuItem click, it must
be be registered to the Menu as an Menu.ItemClickListener .In order to receive item click notifications, the object should : Implement the Menu.ItemClickListener interface
Define the actions that should be performed when a MenuItem is
clicked inside Menu.ItemClickListener.onItemClicked(ItemClickEvent)
Call Menu.addItemClickListener(ItemClickListener) to register
itself to the menu and receive click notifications
|
void |
clearMenu()
Remove all items from the menu.
|
int |
getItemCount()
Returns the items count in a menu.
|
String |
getItemText(int index)
return the text of the item located at the position provided as input.
|
int |
getSelected() |
int |
getSelectedIndex() |
int |
getTabIndex() |
String |
getValue(int index)
return the value of the item located at the position provided as input.
|
boolean |
isEnabled() |
boolean |
isEnabled(int index)
Modify the enabled state of an item.
|
boolean |
isUpgraded() |
void |
removeItem(int index)
Removes an item from the menu.
|
void |
setAccessKey(char key) |
void |
setAnchor(MenuAnchor anchor)
Sets the position of the
Menu on the screen related to its
associated action button using one of the available anchoring options
provided by MenuAnchor .An extra care should be taken when anchoring the menu. |
void |
setEnabled(boolean enable) |
boolean |
setEnabled(int index,
boolean enabled)
Modify the enabled state of an item.
|
void |
setEventSource(Object inputSource) |
void |
setFocus(boolean focused) |
void |
setSelected(int index)
Set a selected item of the dropdown programmatically.
|
void |
setTabIndex(int index) |
void |
upgrade()
Causes the component to be upgraded.
|
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
public Dropdown()
Button
and a menu
anchored to the bottom-left of the action button.public void setEnabled(boolean enable)
setEnabled
in interface IMenuCombo
enable
- see MenuCombo.setEnabled(boolean)
public boolean isEnabled()
isEnabled
in interface IMenuCombo
MenuCombo.isEnabled()
public void setEventSource(Object inputSource)
setEventSource
in interface IHasEventSource
inputSource
- the object designated as the source of events published by the
menupublic final void setAnchor(MenuAnchor anchor)
IMenu
Menu
on the screen related to its
associated action button using one of the available anchoring options
provided by MenuAnchor
.public final void clearMenu()
IMenu
public final void addItemClickListener(Menu.ItemClickListener listener)
IMenu
MenuItem
click, it must
be be registered to the Menu
as an Menu.ItemClickListener
.Menu.ItemClickListener
interfaceMenuItem
is
clicked inside Menu.ItemClickListener.onItemClicked(ItemClickEvent)
Menu.addItemClickListener(ItemClickListener)
to register
itself to the menu and receive click notificationsaddItemClickListener
in interface IMenu
listener
- The object to be notified when a MenuItem
is clicked.Menu.ItemClickListener
public final int getItemCount()
IMenu
getItemCount
in interface IMenu
public final String getItemText(int index)
IMenu
getItemText
in interface IMenu
index
- the position of the itempublic final String getValue(int index)
IMenu
public final boolean setEnabled(int index, boolean enabled)
IMenu
setEnabled
in interface IMenu
index
- the position of the item in the item list of the menuenabled
- the state to be set for the itemtrue
if the state was modified, false
otherwise.public final boolean isEnabled(int index)
IMenu
public final void addItem(String text, String value, boolean enabled)
IMenu
public final void addItem(String item, boolean enabled)
IMenu
IMenu.addItem(String, String, boolean)
where
the text and value are the same.public final void addItem(String item)
item
- the value and text of the item to be addedpublic final void addItem(String text, String value)
addItem(String, boolean)
that adds an enabled
item to the menu.value
- the value of the item to be added.text
- the text of the item to be added.public void addItem(String text, String value, int index, boolean enabled)
IMenu
public final int getSelectedIndex()
public final void setSelected(int index)
index
- the index of the item to be selected or -1 to select none of the
items.public final int getSelected()
public void removeItem(int index)
IMenu
removeItem
in interface IMenu
index
- the position of the item to be removedpublic int getTabIndex()
getTabIndex
in interface com.google.gwt.user.client.ui.Focusable
public void setAccessKey(char key)
setAccessKey
in interface com.google.gwt.user.client.ui.Focusable
public void setFocus(boolean focused)
setFocus
in interface com.google.gwt.user.client.ui.Focusable
public void setTabIndex(int index)
setTabIndex
in interface com.google.gwt.user.client.ui.Focusable
public void upgrade()
IUpgrade
public boolean isUpgraded()
isUpgraded
in interface IUpgrade
Copyright © 2016 com.github.ilyes4j. All rights reserved.