|
|||||||||
| 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.
com.smartgwt.client.widgets.menu.Menu#getData,
Canvas.getContextMenu(),
MenuButton,
MenuBar| 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 |
getAlternateRecordStyles()
Explicitly disable alternateRecordStyles at the menu level by default so setting to true for all ListGrids will not impact menus' appearance. |
Boolean |
getAutoDismiss()
When false, when a menu item is chosen (via mouse click or keyboard), the menu is not automatically hidden, staying in place for further interactivity |
Boolean |
getAutoDismissOnBlur()
When false, when a user clicks outside the menu, or hits the Escape key, this menu will not be automatically hidden, staying in place for further interactivity. |
Boolean |
getAutoDraw()
Menus will not draw on initialization, until they're explicitly show()n |
String |
getBaseStyle()
CSS style for a normal cell |
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. |
Boolean |
getCascadeAutoDismiss()
When true any generated submenus will inherit autoDismiss
from this menu. |
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. |
Boolean |
getFetchSubmenus()
If false, submenus will not be fetched for this menu. |
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. |
static void |
hideAllMenus()
Hide all menus that are currently open. |
void |
hideContextMenu()
Hide the context menu - alias for hide() |
protected void |
onInit_ListGrid()
|
void |
removeItem(MenuItem item)
|
void |
setAlternateRecordStyles(Boolean alternateRecordStyles)
Explicitly disable alternateRecordStyles at the menu level by default so setting to true for all ListGrids will not impact menus' appearance. |
void |
setAutoDismiss(Boolean autoDismiss)
When false, when a menu item is chosen (via mouse click or keyboard), the menu is not automatically hidden, staying in place for further interactivity |
void |
setAutoDismissOnBlur(Boolean autoDismissOnBlur)
When false, when a user clicks outside the menu, or hits the Escape key, this menu will not be 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 |
setBaseStyle(String baseStyle)
CSS style for a normal cell |
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 |
setCascadeAutoDismiss(Boolean cascadeAutoDismiss)
When true any generated submenus will inherit autoDismiss
from this menu. |
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 |
setData(Tree data)
Display a hierarchical set of menu items and submenus based on a Tree of data. |
static void |
setDefaultProperties(Menu menuProperties)
Class level method to set the default properties of this class. |
void |
setDefaultWidth(int defaultWidth)
The default menu width. |
void |
setEmptyMessage(String emptyMessage)
Message to show when a menu is shown with no items. |
void |
setFetchSubmenus(Boolean fetchSubmenus)
If false, submenus will not be fetched for this menu. |
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. |
Boolean |
setItemChecked(int item)
Checks or unchecks the menu item according to the value of newState, and redraws the menu if necessary. |
Boolean |
setItemChecked(int item,
boolean newState)
Checks or unchecks the menu item according to the value of newState, and redraws the menu if necessary. |
Boolean |
setItemChecked(MenuItem item)
Checks or unchecks the menu item according to the value of newState, and redraws the menu if necessary. |
Boolean |
setItemChecked(MenuItem item,
boolean newState)
Checks or unchecks the menu item according to the value of newState, and redraws the menu if necessary. |
Boolean |
setItemEnabled(int item)
Enables or disables the menu item according to the value of newState, and redraws the menu if necessary. |
Boolean |
setItemEnabled(int item,
boolean newState)
Enables or disables the menu item according to the value of newState, and redraws the menu if necessary. |
Boolean |
setItemEnabled(MenuItem item)
Enables or disables the menu item according to the value of newState, and redraws the menu if necessary. |
Boolean |
setItemEnabled(MenuItem item,
boolean newState)
Enables or disables the menu item according to the value of newState, and redraws the menu if necessary. |
Boolean |
setItemIcon(int item,
String newIcon)
Sets the icon and disabled icon (if specified) for a particular menu item and redraws the menu if necessary. |
Boolean |
setItemIcon(int item,
String newIcon,
String newDisabledIcon)
Sets the icon and disabled icon (if specified) for a particular menu item and redraws the menu if necessary. |
Boolean |
setItemIcon(MenuItem item,
String newIcon)
Sets the icon and disabled icon (if specified) for a particular menu item and redraws the menu if necessary. |
Boolean |
setItemIcon(MenuItem item,
String newIcon,
String newDisabledIcon)
Sets the icon and disabled icon (if specified) for a particular menu item and redraws the menu if necessary. |
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...). |
Boolean |
setItemTitle(int item,
String newTitle)
Sets the title of a particular menu item to the string specified by newTitle and redraws the menu if necessary. |
Boolean |
setItemTitle(MenuItem item,
String newTitle)
Sets the title of a particular menu item to the string specified by newTitle and redraws the menu if necessary. |
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 |
|---|
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, 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, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, sinkBitlessEvent, 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 ListGridpublic void setAlternateRecordStyles(Boolean alternateRecordStyles)
setAlternateRecordStyles in class ListGridalternateRecordStyles - alternateRecordStyles Default value is falsepublic Boolean getAlternateRecordStyles()
getAlternateRecordStyles in class ListGridpublic void setAutoDismiss(Boolean autoDismiss)
autoDismiss - autoDismiss Default value is truesetCascadeAutoDismiss(java.lang.Boolean)public Boolean getAutoDismiss()
getCascadeAutoDismiss()public void setAutoDismissOnBlur(Boolean autoDismissOnBlur)
autoDismissOnBlur - autoDismissOnBlur Default value is truepublic Boolean getAutoDismissOnBlur()
public void setAutoDraw(Boolean autoDraw)
Note : This is an advanced setting
setAutoDraw in class CanvasautoDraw - autoDraw Default value is falseDrawing overview and related methodspublic Boolean getAutoDraw()
getAutoDraw in class CanvasDrawing overview and related methodspublic void setBaseStyle(String baseStyle)
setBaseStyle in class ListGridbaseStyle - baseStyle Default value is "menu"Appearance overview and related methodspublic String getBaseStyle()
getBaseStyle in class ListGridAppearance overview and related methodspublic void setCanSelectParentItems(Boolean canSelectParentItems)
canSelectParentItems - canSelectParentItems Default value is nullSelection overview and related methods,
Tree Binding Examplepublic Boolean getCanSelectParentItems()
Selection overview and related methods,
Tree Binding Examplepublic void setCascadeAutoDismiss(Boolean cascadeAutoDismiss)
autoDismiss
from this menu.
cascadeAutoDismiss - cascadeAutoDismiss Default value is truepublic Boolean getCascadeAutoDismiss()
autoDismiss
from this menu.
public void setCellHeight(int cellHeight)
setCellHeight in class ListGridcellHeight - cellHeight Default value is 20Sizing overview and related methodspublic int getCellHeight()
getCellHeight in class ListGridSizing overview and related methodspublic void setDefaultWidth(int defaultWidth)
setDefaultWidth in class CanvasdefaultWidth - defaultWidth Default value is 150Sizing overview and related methodspublic int getDefaultWidth()
getDefaultWidth in class CanvasSizing overview and related methodspublic void setEmptyMessage(String emptyMessage)
Note : This is an advanced setting
setEmptyMessage in class ListGridemptyMessage - emptyMessage Default value is "[Empty menu]"ListGrid.setShowEmptyMessage(java.lang.Boolean),
ListGrid.setEmptyMessageStyle(java.lang.String),
Empty grid Examplepublic String getEmptyMessage()
getEmptyMessage in class ListGridListGrid.getShowEmptyMessage(),
ListGrid.getEmptyMessageStyle(),
Empty grid Example
public void setFetchSubmenus(Boolean fetchSubmenus)
throws IllegalStateException
fetchSubmenus.
fetchSubmenus - fetchSubmenus Default value is true
IllegalStateException - this property cannot be changed after the component has been createdpublic Boolean getFetchSubmenus()
fetchSubmenus.
public void setIconHeight(int iconHeight)
iconHeight - iconHeight Default value is 16public int getIconHeight()
public void setIconWidth(int iconWidth)
iconWidth - iconWidth Default value is 16public int getIconWidth()
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 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 setShowIcons(Boolean showIcons)
showIcons - showIcons Default value is truepublic Boolean getShowIcons()
public void setShowKeys(Boolean showKeys)
showKeys - showKeys Default value is truepublic Boolean getShowKeys()
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 setTarget(Canvas target)
MenuItem.checkIf. Whenever a Menu is shown as a contextMenu by a
widget due to contextMenu being set, menu.target
is automatically set to the widget that showed the contextMenu.
If this item has any submenus the target will be propagated down to these
child menus.
target - target Default value is nullpublic Canvas getTarget()
MenuItem.checkIf. Whenever a Menu is shown as a contextMenu by a
widget due to contextMenu being set, menu.target
is automatically set to the widget that showed the contextMenu.
If this item has any submenus the target will be propagated down to these
child menus.
public void setUseKeys(Boolean useKeys)
useKeys - useKeys Default value is truepublic Boolean getUseKeys()
public MenuItem getItem(int item)
If passed a MenuItem, returns it.
item - index of the MenuItem
public void hideContextMenu()
hideContextMenu in class Canvaspublic 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 HasItemClickHandlershandler - the itemClick handler
HandlerRegistration used to remove this handlerpublic Boolean showContextMenu()
Visibility overview and related methodspublic static void hideAllMenus()
public static void setDefaultProperties(Menu menuProperties)
Note: This method is intended for setting default attributes only and will effect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead.
menuProperties - properties that should be used as new defaults when instances of this class are createdprotected void onInit_ListGrid()
onInit_ListGrid in class ListGridpublic void setData(MenuItem... data)
data - menu itemspublic void setData(Record[] data)
setData in class ListGriddata - array of Record objects.setData(MenuItem[])public void setData(Tree data)
data - Treepublic void setData(RecordList data)
setData in class ListGriddata - 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 Canvastitle - 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 itempublic Boolean setItemChecked(MenuItem item)
item - MenuItem in question, or it's index
public Boolean setItemChecked(int item)
item - MenuItem in question, or it's index
public Boolean setItemChecked(MenuItem item,
boolean newState)
item - MenuItem in question, or it's indexnewState - true to check the menu item, false to uncheck it. If not passed, true is assumed
public Boolean setItemChecked(int item,
boolean newState)
item - MenuItem in question, or it's indexnewState - true to check the menu item, false to uncheck it. If not passed, true is assumed
public Boolean setItemEnabled(MenuItem item)
item - MenuItem in question, or it's index
public Boolean setItemEnabled(int item)
item - MenuItem in question, or it's index
public Boolean setItemEnabled(MenuItem item,
boolean newState)
item - MenuItem in question, or it's indexnewState - true to enable the menu item, false to disable it. If not passed, true is assumed
public Boolean setItemEnabled(int item,
boolean newState)
item - MenuItem in question, or it's indexnewState - true to enable the menu item, false to disable it. If not passed, true is assumed
public Boolean setItemIcon(MenuItem item,
String newIcon)
item - MenuItem in question, or it's indexnewIcon - new icon URL
public Boolean setItemIcon(int item,
String newIcon)
item - MenuItem in question, or it's indexnewIcon - new icon URL
public Boolean setItemIcon(MenuItem item,
String newIcon,
String newDisabledIcon)
item - MenuItem in question, or it's indexnewIcon - new icon URLnewDisabledIcon - new icon URL for disabled image
public Boolean setItemIcon(int item,
String newIcon,
String newDisabledIcon)
item - MenuItem in question, or it's indexnewIcon - new icon URLnewDisabledIcon - new icon URL for disabled image
public Boolean setItemTitle(MenuItem item,
String newTitle)
item - MenuItem in question, or it's indexnewTitle - new title
public Boolean setItemTitle(int item,
String newTitle)
item - MenuItem in question, or it's indexnewTitle - new title
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||