|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.smartgwt.client.widgets.BaseWidget
com.smartgwt.client.widgets.Canvas
com.smartgwt.client.widgets.grid.ListGrid
com.smartgwt.client.widgets.menu.Menu
public class Menu
The Menu widget class implements interactive menu widgets, with optional icons, submenus, and shortcut keys.
A Menu is initialized with an Array of items, specified as menu.data, each of which represents one row in the menu's display and specifies the action to take when that menu item is selected.
Generally to create a context menu for a
component, provide a Menu instance for the contextMenu
property. Note that some components have special
context menu support because they have distinct regions or because they have a default set of context menu actions
available.
If you want a button that pops up a menu when clicked, or a bar of such buttons, see the MenuButton and MenuBar classes.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject |
---|
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled |
Field Summary |
---|
Fields inherited from class com.smartgwt.client.widgets.BaseWidget |
---|
config, configOnly, id, isElementSet, scClassName |
Fields inherited from class com.google.gwt.user.client.ui.UIObject |
---|
DEBUG_ID_PREFIX |
Constructor Summary | |
---|---|
Menu()
|
|
Menu(JavaScriptObject jsObj)
|
Method Summary | |
---|---|
void |
addItem(MenuItem item)
|
void |
addItem(MenuItem item,
int index)
|
HandlerRegistration |
addItemClickHandler(ItemClickHandler handler)
Add a itemClick handler. |
protected JavaScriptObject |
create()
|
Boolean |
getAutoDismiss()
When true, when a menu item is chosen (via mouse click or keyboard), the menu is not automatically hidden, staying in place for further interactivity |
Boolean |
getAutoDraw()
Menus will not draw on initialization, until they're explicitly show()n |
Boolean |
getCanSelectParentItems()
If true, clicking or pressing Enter on a menu item that has a submenu will select that item (with standard behavior of hiding the menus, calling click handlers, etc) instead of showing the submenu. |
int |
getCellHeight()
The height of each item in the menu, in pixels. |
int |
getDefaultWidth()
The default menu width. |
String |
getEmptyMessage()
Message to show when a menu is shown with no items. |
int |
getIconHeight()
The default height applied to custom icons in this menu. |
int |
getIconWidth()
The default width applied to custom icons in this menu. |
MenuItem |
getItem(int item)
Get a particular MenuItem by index. |
int |
getItemNum(MenuItem item)
Given a MenuItem, return it's index in the items array. |
MenuItem[] |
getItems()
Return the menu items. |
Integer |
getMenuButtonWidth()
For a menu that has a MenuButton generated for it automatically (for example
when included in a MenuBar , the width that the MenuButton should have. |
static Menu |
getOrCreateRef(JavaScriptObject jsObj)
|
String |
getShowAnimationEffect()
When this menu is shown how should it animate into view? By default the menu will just show at the specified size/position. |
Boolean |
getShowIcons()
A boolean, indicating whether the checkmark/custom icon column should be displayed. |
Boolean |
getShowKeys()
A boolean, indicating whether the shortcut key column should be displayed. |
Boolean |
getShowSubmenus()
A boolean, indicating whether the submenu indicator column should be displayed. |
String |
getSubmenuDirection()
Should submenus show up on our left or right. |
Canvas |
getTarget()
Optional target canvas for this menu. |
Boolean |
getUseKeys()
A boolean indicating whether this menu should use shortcut keys. |
void |
hideContextMenu()
Hide the context menu - alias for hide() |
protected void |
onInit()
|
void |
removeItem(MenuItem item)
|
void |
setAutoDismiss(Boolean autoDismiss)
When true, when a menu item is chosen (via mouse click or keyboard), the menu is not automatically hidden, staying in place for further interactivity |
void |
setAutoDraw(Boolean autoDraw)
Menus will not draw on initialization, until they're explicitly show()n |
void |
setCanSelectParentItems(Boolean canSelectParentItems)
If true, clicking or pressing Enter on a menu item that has a submenu will select that item (with standard behavior of hiding the menus, calling click handlers, etc) instead of showing the submenu. |
void |
setCellHeight(int cellHeight)
The height of each item in the menu, in pixels. |
void |
setData(MenuItem... data)
An array of menuItem objects, specifying the menu items this menu should show. |
void |
setData(Record[] data)
An array of Record objects, specifying the data to be used to populate the DataBoundComponent. |
void |
setData(RecordList data)
An List of Record objects, specifying the data to be used to populate the DataBoundComponent. |
void |
setDefaultWidth(int defaultWidth)
The default menu width. |
void |
setEmptyMessage(String emptyMessage)
Message to show when a menu is shown with no items. |
void |
setIconHeight(int iconHeight)
The default height applied to custom icons in this menu. |
void |
setIconWidth(int iconWidth)
The default width applied to custom icons in this menu. |
void |
setItemProperties(int item,
MenuItem properties)
Set arbitrary properties for a particular menu item. |
void |
setItems(MenuItem... items)
Synonym for data Synonym for setData(com.smartgwt.client.widgets.menu.MenuItem...) . |
void |
setMenuButtonWidth(Integer menuButtonWidth)
For a menu that has a MenuButton generated for it automatically (for example
when included in a MenuBar , the width that the MenuButton should have. |
void |
setShowAnimationEffect(String showAnimationEffect)
When this menu is shown how should it animate into view? By default the menu will just show at the specified size/position. |
void |
setShowIcons(Boolean showIcons)
A boolean, indicating whether the checkmark/custom icon column should be displayed. |
void |
setShowKeys(Boolean showKeys)
A boolean, indicating whether the shortcut key column should be displayed. |
void |
setShowSubmenus(Boolean showSubmenus)
A boolean, indicating whether the submenu indicator column should be displayed. |
void |
setSubmenuDirection(String submenuDirection)
Should submenus show up on our left or right. |
void |
setTarget(Canvas target)
Optional target canvas for this menu. |
void |
setTitle(String title)
When used in a MenuBar, the title of the menu button create will be the title of the Menu. |
void |
setUseKeys(Boolean useKeys)
A boolean indicating whether this menu should use shortcut keys. |
Boolean |
showContextMenu()
Show this menu as a context menu, that is, immediately adjacent to the current mouse position. |
Methods inherited from class com.google.gwt.user.client.ui.Widget |
---|
addDomHandler, addHandler, delegateEvent, doAttachChildren, doDetachChildren, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents |
Methods inherited from class com.google.gwt.user.client.ui.UIObject |
---|
addStyleDependentName, ensureDebugId, ensureDebugId, ensureDebugId, getStyleElement, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setPixelSize, setSize, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, unsinkEvents |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.google.gwt.event.shared.HasHandlers |
---|
fireEvent |
Methods inherited from interface com.smartgwt.client.widgets.DataBoundComponent |
---|
getOrCreateJsObj |
Constructor Detail |
---|
public Menu()
public Menu(JavaScriptObject jsObj)
Method Detail |
---|
public static Menu getOrCreateRef(JavaScriptObject jsObj)
protected JavaScriptObject create()
create
in class ListGrid
public void setTarget(Canvas target)
MenuItem.checkIf(com.smartgwt.client.widgets.Canvas, com.smartgwt.client.widgets.menu.Menu, com.smartgwt.client.widgets.menu.MenuItem)
. If this item has any 'submenus'
the target
will be propogated down to
these child menus.
target
- target Default value is nullpublic Canvas getTarget()
MenuItem.checkIf(com.smartgwt.client.widgets.Canvas, com.smartgwt.client.widgets.menu.Menu, com.smartgwt.client.widgets.menu.MenuItem)
. If this item has any 'submenus'
the target
will be propogated down to
these child menus.
public void setDefaultWidth(int defaultWidth)
setDefaultWidth
in class Canvas
defaultWidth
- defaultWidth Default value is 150public int getDefaultWidth()
getDefaultWidth
in class Canvas
public void setCellHeight(int cellHeight)
setCellHeight
in class ListGrid
cellHeight
- cellHeight Default value is 20public int getCellHeight()
getCellHeight
in class ListGrid
public void setAutoDraw(Boolean autoDraw)
Note : This is an advanced setting
autoDraw
- autoDraw Default value is falsepublic Boolean getAutoDraw()
public void setUseKeys(Boolean useKeys)
useKeys
- useKeys Default value is truepublic Boolean getUseKeys()
public void setShowKeys(Boolean showKeys)
showKeys
- showKeys Default value is truepublic Boolean getShowKeys()
public void setShowIcons(Boolean showIcons)
showIcons
- showIcons Default value is truepublic Boolean getShowIcons()
public void setShowSubmenus(Boolean showSubmenus)
showSubmenus
- showSubmenus Default value is truepublic Boolean getShowSubmenus()
public void setSubmenuDirection(String submenuDirection)
"left"
or "right"
submenuDirection
- submenuDirection Default value is "right"public String getSubmenuDirection()
"left"
or "right"
public void setEmptyMessage(String emptyMessage)
Note : This is an advanced setting
setEmptyMessage
in class ListGrid
emptyMessage
- emptyMessage Default value is "[Empty menu]"public String getEmptyMessage()
getEmptyMessage
in class ListGrid
public void setIconWidth(int iconWidth)
iconWidth
- iconWidth Default value is 16public int getIconWidth()
public void setIconHeight(int iconHeight)
iconHeight
- iconHeight Default value is 16public int getIconHeight()
public void setShowAnimationEffect(String showAnimationEffect)
"fade"
to fade from transparent to visible,
"slide"
to slide the menu into view, or "wipe"
to have the menu grow into view, revealing its
content as it grows. Can be overridden by passing the 'animationEffect' parameter to 'menu.show()'
Note : This is an advanced setting
showAnimationEffect
- showAnimationEffect Default value is nullpublic String getShowAnimationEffect()
"fade"
to fade from transparent to visible,
"slide"
to slide the menu into view, or "wipe"
to have the menu grow into view, revealing its
content as it grows. Can be overridden by passing the 'animationEffect' parameter to 'menu.show()'
public void setCanSelectParentItems(Boolean canSelectParentItems)
canSelectParentItems
- canSelectParentItems Default value is nullpublic Boolean getCanSelectParentItems()
public void setAutoDismiss(Boolean autoDismiss)
autoDismiss
- autoDismiss Default value is truepublic Boolean getAutoDismiss()
public void setMenuButtonWidth(Integer menuButtonWidth) throws IllegalStateException
MenuButton
generated for it automatically (for example
when included in a MenuBar
, the width that the MenuButton should have. If
unset, the MenuButton will be as wide as menu.width
.
menuButtonWidth
- menuButtonWidth Default value is null
IllegalStateException
- this property cannot be changed after the component has been createdpublic Integer getMenuButtonWidth()
MenuButton
generated for it automatically (for example
when included in a MenuBar
, the width that the MenuButton should have. If
unset, the MenuButton will be as wide as menu.width
.
public HandlerRegistration addItemClickHandler(ItemClickHandler handler)
Executed when a menu item with no click handler is clicked by the user. This itemClick handler must be specified as a function. It is passed an item parameter that is a reference to the clicked menu item.
addItemClickHandler
in interface HasItemClickHandlers
handler
- the itemClick handler
HandlerRegistration
used to remove this handlerpublic Boolean showContextMenu()
public void hideContextMenu()
hideContextMenu
in class Canvas
public MenuItem getItem(int item)
If passed a MenuItem, returns it.
item
- index of the MenuItem
protected void onInit()
onInit
in class ListGrid
public void setData(MenuItem... data)
data
- menu itemspublic void setData(Record[] data)
setData
in class ListGrid
data
- array of Record objects.setData(MenuItem[])
public void setData(RecordList data)
setData
in class ListGrid
data
- List of Recordspublic void setItems(MenuItem... items)
data
Synonym for setData(com.smartgwt.client.widgets.menu.MenuItem...)
.
items
- new items for this menu. Default value is nullpublic MenuItem[] getItems()
public void setTitle(String title)
setTitle
in class Canvas
title
- the titlepublic void removeItem(MenuItem item)
public void addItem(MenuItem item)
public void addItem(MenuItem item, int index)
public int getItemNum(MenuItem item)
item
- the MenuItem
public void setItemProperties(int item, MenuItem properties)
item
- index of the MenuItemproperties
- properties to apply to the item
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |