java.lang.Object | |||
↳ | com.google.gwt.user.client.ui.UIObject | ||
↳ | com.google.gwt.user.client.ui.Widget | ||
↳ | com.google.gwt.user.client.ui.MenuBar |
A standard menu bar widget. A menu bar can contain any number of menu items,
each of which can either fire a Command
or
open a cascaded menu bar.
MenuBar elements in UiBinder template files can have a vertical
boolean attribute (which defaults to false), and may have only MenuItem
elements as children. MenuItems may contain HTML and MenuBars.
For example:
<g:MenuBar> <g:MenuItem>Higgledy <g:MenuBar vertical="true"> <g:MenuItem>able</g:MenuItem> <g:MenuItem>baker</g:MenuItem> <g:MenuItem>charlie</g:MenuItem> </g:MenuBar> </g:MenuItem> <g:MenuItem>Piggledy <g:MenuBar vertical="true"> <g:MenuItem>foo</g:MenuItem> <g:MenuItem>bar</g:MenuItem> <g:MenuItem>baz</g:MenuItem> </g:MenuBar> </g:MenuItem> <g:MenuItem><b>Pop!</b> <g:MenuBar vertical="true"> <g:MenuItem>uno</g:MenuItem> <g:MenuItem>dos</g:MenuItem> <g:MenuItem>tres</g:MenuItem> </g:MenuBar> </g:MenuItem> </g:MenuBar>
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
MenuBar.MenuBarImages |
This interface is deprecated.
replaced by MenuBar.Resources
|
||||||||||
MenuBar.Resources | A ClientBundle that contains the default resources for this widget. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.google.gwt.user.client.ui.UIObject
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates an empty horizontal menu bar.
| |||||||||||
Creates an empty menu bar.
| |||||||||||
This constructor is deprecated.
replaced by
MenuBar(boolean, Resources)
| |||||||||||
Creates an empty menu bar that uses the specified ClientBundle for menu
images.
| |||||||||||
This constructor is deprecated.
replaced by
MenuBar(Resources)
| |||||||||||
Creates an empty horizontal menu bar that uses the specified ClientBundle
for menu images.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds a menu item to the bar.
| |||||||||||
Adds a menu item to the bar, that will open the specified menu when it is
selected.
| |||||||||||
Adds a menu item to the bar, that will open the specified menu when it is
selected.
| |||||||||||
Adds a menu item to the bar containing SafeHtml, that will fire the given
command when it is selected.
| |||||||||||
Adds a menu item to the bar, that will fire the given command when it is
selected.
| |||||||||||
Adds a menu item to the bar, that will open the specified menu when it is
selected.
| |||||||||||
Adds a menu item to the bar, that will fire the given command when it is
selected.
| |||||||||||
Removes all menu items from this menu bar.
| |||||||||||
Closes this menu and all child menu popups.
| |||||||||||
Give this MenuBar focus.
| |||||||||||
Gets whether this menu bar's child menus will open when the mouse is moved
over it.
| |||||||||||
Get the index of a
MenuItem . | |||||||||||
Get the index of a
MenuItemSeparator . | |||||||||||
Adds a menu item to the bar at a specific index.
| |||||||||||
Returns true if animations are enabled, false if not.
| |||||||||||
Check whether or not this widget will steal keyboard focus when the mouse
hovers over it.
| |||||||||||
Moves the menu selection down to the next item.
| |||||||||||
Moves the menu selection up to the previous item.
| |||||||||||
Fired whenever a browser event is received.
| |||||||||||
This method is deprecated.
Use
addCloseHandler(CloseHandler) instead
| |||||||||||
Removes the specified menu item from the bar.
| |||||||||||
Removes the specified
MenuItemSeparator from the bar. | |||||||||||
Select the given MenuItem, which must be a direct child of this MenuBar.
| |||||||||||
Enable or disable animations.
| |||||||||||
Sets whether this menu bar's child menus will open when the mouse is moved
over it.
| |||||||||||
Enable or disable auto focus when the mouse hovers over the MenuBar.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns a list containing the
MenuItem objects in the menu
bar. | |||||||||||
Returns the
MenuItem that is currently selected (highlighted)
by the user. | |||||||||||
This method is called when a widget is detached from the browser's document. | |||||||||||
Affected Elements:
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.google.gwt.user.client.ui.Widget
| |||||||||||
From class
com.google.gwt.user.client.ui.UIObject
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface com.google.gwt.event.logical.shared.HasAttachHandlers | |||||||||||
From interface com.google.gwt.event.logical.shared.HasCloseHandlers | |||||||||||
From interface com.google.gwt.event.shared.HasHandlers | |||||||||||
From interface
com.google.gwt.user.client.EventListener
| |||||||||||
From interface
com.google.gwt.user.client.ui.HasAnimation
| |||||||||||
From interface
com.google.gwt.user.client.ui.IsWidget
| |||||||||||
From interface
com.google.gwt.user.client.ui.PopupListener
|
Creates an empty horizontal menu bar.
Creates an empty menu bar.
vertical | true to orient the menu bar vertically
|
---|
This constructor is deprecated.
replaced by MenuBar(boolean, Resources)
Creates an empty menu bar that uses the specified image bundle for menu images.
vertical | true to orient the menu bar vertically |
---|---|
images | a bundle that provides images for this menu |
Creates an empty menu bar that uses the specified ClientBundle for menu images.
vertical | true to orient the menu bar vertically |
---|---|
resources | a bundle that provides images for this menu |
This constructor is deprecated.
replaced by MenuBar(Resources)
Creates an empty horizontal menu bar that uses the specified image bundle for menu images.
images | a bundle that provides images for this menu |
---|
Creates an empty horizontal menu bar that uses the specified ClientBundle for menu images.
resources | a bundle that provides images for this menu |
---|
Adds a menu item to the bar, that will open the specified menu when it is selected.
html | the item's html text |
---|---|
popup | the menu to be cascaded from it |
MenuItem
object created
Adds a menu item to the bar, that will open the specified menu when it is selected.
text | the item's text |
---|---|
popup | the menu to be cascaded from it |
MenuItem
object created
Adds a menu item to the bar containing SafeHtml, that will fire the given command when it is selected.
html | the item's html text |
---|---|
cmd | the command to be fired |
MenuItem
object created
Adds a menu item to the bar, that will fire the given command when it is selected.
text | the item's text |
---|---|
asHTML | true to treat the specified text as html |
cmd | the command to be fired |
MenuItem
object created
Adds a menu item to the bar, that will open the specified menu when it is selected.
text | the item's text |
---|---|
asHTML | true to treat the specified text as html |
popup | the menu to be cascaded from it |
MenuItem
object created
Adds a menu item to the bar, that will fire the given command when it is selected.
text | the item's text |
---|---|
cmd | the command to be fired |
MenuItem
object created
separator | the MenuItemSeparator to be added |
---|
MenuItemSeparator
object
Removes all menu items from this menu bar.
Closes this menu and all child menu popups.
focus | true to move focus to the parent |
---|
Give this MenuBar focus.
Gets whether this menu bar's child menus will open when the mouse is moved over it.
true
if child menus will auto-open
Get the index of a MenuItem
.
Get the index of a MenuItemSeparator
.
Adds a menu item to the bar at a specific index.
item | the item to be inserted |
---|---|
beforeIndex | the index where the item should be inserted |
MenuItem
objectIndexOutOfBoundsException | if beforeIndex is out of
range
|
---|
separator | the MenuItemSeparator to be inserted |
---|---|
beforeIndex | the index where the separator should be inserted |
MenuItemSeparator
objectIndexOutOfBoundsException | if beforeIndex is out of
range
|
---|
beforeIndex | the index where the separator should be inserted |
---|
MenuItemSeparator
objectIndexOutOfBoundsException | if beforeIndex is out of
range
|
---|
Returns true if animations are enabled, false if not.
Check whether or not this widget will steal keyboard focus when the mouse hovers over it.
Moves the menu selection down to the next item. If there is no selection, selects the first item. If there are no items at all, does nothing.
Moves the menu selection up to the previous item. If there is no selection, selects the first item. If there are no items at all, does nothing.
Fired whenever a browser event is received.
event | the event received |
---|
This method is deprecated.
Use addCloseHandler(CloseHandler)
instead
Closes the menu bar.
sender | popup being closed. |
---|---|
autoClosed | true if the popup was automatically closed;
false if it was closed programmatically. |
Removes the specified menu item from the bar.
item | the item to be removed |
---|
Removes the specified MenuItemSeparator
from the bar.
separator | the separator to be removed |
---|
Select the given MenuItem, which must be a direct child of this MenuBar.
item | the MenuItem to select, or null to clear selection |
---|
Enable or disable animations.
enable | true to enable, false to disable |
---|
Sets whether this menu bar's child menus will open when the mouse is moved over it.
autoOpen | true to cause child menus to auto-open
|
---|
Enable or disable auto focus when the mouse hovers over the MenuBar. This allows the MenuBar to respond to keyboard events without the user having to click on it, but it will steal focus from other elements on the page. Enabled by default.
enabled | true to enable, false to disable |
---|
Returns a list containing the MenuItem
objects in the menu
bar. If there are no items in the menu bar, then an empty List
object will be returned.
MenuItem
objects in the menu bar
Returns the MenuItem
that is currently selected (highlighted)
by the user. If none of the items in the menu are currently selected, then
null
will be returned.
MenuItem
that is currently selected, or
null
if no items are currently selected
This method is called when a widget is detached from the browser's
document. To receive notification before a Widget is removed from the
document, override the onUnload()
method or use addAttachHandler(AttachEvent.Handler)
.
It is strongly recommended that you override onUnload()
or
doDetachChildren()
instead of this method to avoid inconsistencies
between logical and physical attachment states.
Subclasses that override this method must call
super.onDetach()
to ensure that the Widget has been detached
from the underlying Element. Failure to do so will result in application
memory leaks due to circular references between DOM Elements and JavaScript
objects.
Affected Elements:
MenuItem
at the specified index.baseID | the base ID used by the main element |
---|