Gambas Documentation
Application Repository
Code Snippets
Compilation & Installation
Components
gb
gb.args
gb.cairo
gb.chart
gb.clipper
gb.complex
gb.compress
gb.crypt
gb.data
gb.db
gb.db.form
gb.db.mysql
gb.db.odbc
gb.db.postgresql
gb.db.sqlite2
gb.db.sqlite3
gb.dbus
gb.dbus.trayicon
gb.debug
gb.desktop
gb.desktop.gnome.keyring
gb.desktop.x11
gb.eval
gb.eval.highlight
gb.form
gb.form.dialog
gb.form.editor
gb.form.htmlview
gb.form.mdi
gb.form.print
gb.form.stock
gb.form.terminal
gb.gmp
gb.gsl
gb.gtk
gb.gtk.opengl
gb.gtk3
gb.gtk3.opengl
gb.gtk3.webview
gb.gui
gb.gui.opengl
gb.gui.qt
gb.gui.qt.ext
gb.gui.qt.opengl
gb.gui.qt.webkit
gb.gui.trayicon
gb.gui.webview
gb.hash
gb.highlight
gb.image
gb.image.effect
gb.image.imlib
gb.image.io
gb.inotify
gb.jit
gb.libxml
gb.logging
gb.map
gb.markdown
gb.media
gb.media.form
gb.memcached
gb.mime
gb.mongodb
gb.mysql
gb.ncurses
gb.net
gb.net.curl
gb.net.pop3
gb.net.smtp
gb.openal
gb.opengl
gb.opengl.glsl
gb.opengl.glu
gb.opengl.sge
gb.openssl
gb.option
gb.pcre
gb.pdf
gb.poppler
gb.qt4
.combobox.item
.container.children
.Menu.Children
.TabStripContainer
.TabStripContainer.Children
.TextArea.Selection
.TextBox.Selection
.Window.Controls
.Window.Menus
_ColumnView_Columns
_ComboBox_Item
_ComboBox_Selection
_Draw_Clip
_Draw_Style
_GridView_Cell
_GridView_Column
_GridView_Columns
_GridView_Data
_GridView_Row
_GridView_Rows
_Gui
_IconView_Item
_ListBox_Item
_split
_TreeView
_TreeView_Item
Action
Align
Animation
Application
Arrange
Border
Button
CheckBox
Clipboard
Color
ColumnView
ComboBox
Container
ContainerChildren
Control
Cursor
Desktop
Dialog
Direction
Drag
Draw
DrawingArea
embedder
Fill
Font
Fonts
Form
Frame
GridView
HBox
HPanel
HSplit
IconView
Image
Key
Label
Line
ListBox
ListView
Menu
_new
Action
Caption
Checked
Children
Click
Close
Closed
Delete
Enabled
Hide
Hide
Name
Parent
Picture
Popup
Proxy
Radio
Shortcut
Show
Show
Tag
Text
Toggle
Value
Visible
Window
Message
Mouse
MovieBox
Paint
PaintBrush
PaintExtents
PaintMatrix
Panel
Picture
PictureBox
Point
Pointer
PointF
Printer
ProgressBar
RadioButton
Rect
RectF
Screen
Screens
Scroll
ScrollArea
ScrollBar
ScrollView
Select
Separator
Slider
SpinBox
Splitter
Spring
Style
SvgImage
TabStrip
TextArea
TextBox
TextLabel
ToggleButton
ToolButton
trayicon
trayicons
TreeView
UserContainer
UserControl
VBox
VPanel
VSplit
Watcher
Window
Windows
gb.qt4.ext
gb.qt4.opengl
gb.qt4.webkit
gb.qt4.webview
gb.qt5
gb.qt5.ext
gb.qt5.opengl
gb.qt5.webkit
gb.qt5.webview
gb.qt6
gb.qt6.ext
gb.qt6.opengl
gb.qt6.webview
gb.report
gb.report2
gb.scanner
gb.sdl
gb.sdl.sound
gb.sdl2
gb.sdl2.audio
gb.settings
gb.signal
gb.term
gb.test
gb.util
gb.util.web
gb.v4l
gb.vb
gb.web
gb.web.feed
gb.web.form
gb.web.gui
gb.xml
gb.xml.html
gb.xml.rpc
gb.xml.xslt
Controls pictures
Deprecated components
Developer Documentation
Development Environment Documentation
Documents
Error Messages
Gambas Playground
How To's
Language Index
Language Overviews
Last Changes
Lexicon
README
Search the wiki
To Do
Topics
Tutorials
Wiki License
Wiki Manual

Menu (gb.qt4)

This class represents a popup menu, or one element of a popup menu.

This class is creatable.

Properties
Action   Returns or sets the action string associated with the control.
Caption   A synonymous for the Text property.
Checked   Indicates if a menu is checked.
Children   Returns a collection of each child of the menu.
Closed   Return if a menu is closed.
Enabled   Indicates if the menu is enabled.
Name   Returns or sets the name of the menu control.
Parent   Return the parent of the menu, or NULL the menu is a top-level menu.
Picture   Returns or sets the icon displayed in the menu.
Proxy   Return or set the proxy of a menu.
Radio   Return or set if a menu acts like a radio button.
Shortcut   Returns or sets the shorcut key name of the menu.
Tag   Returns or sets the tag associated with the menu.
Text   Returns or sets the text displayed in the menu.
Toggle   Returns or sets if this Menu acts like a toggle.
Value   A synonymous for the Checked property.
Visible   Indicates if the menu is visible.
Window   Returns the Window this Menu belongs to.

Methods
Close   Close an opened popup menu.
Delete   Deletes the menu.
Hide   Hides a menu.
Popup   Open the menu under the mouse, and waits until it is closed.
Show   Shows the menu.

Events
Click   Raised when the user clicked on the menu.
Hide   This event is raised just after the menu has been hidden.
Show   Raised just before the menu is shown.

Creating a popup menu.

A popup menu is built by creating a hierarchy tree of Menu objects.

  • Each menu of the hierarchy having children becomes a sub-menu.

  • Each leaf of the hirerachy tree becomes a menu entry.

  • The root menu must be a top-level menu (see below).

Top-level menus

To create a top-level menu, i.e. an entry in the menu bar, the window must be the parent object of the menu.

As soon as a window has at least one visible top-level menu, the window menu bar becomes visible. Otherwise, it is hidden.

The Unity desktop removes the menu bar from the application window to put it on the top desktop panel.

Alas, it does not work well on windows that are not top-level windows, but embedded windows (like the Workspace control does).

To workaround the problem, run the following code at the very beginning of your program:
Application.Env["APPMENU_DISPLAY_BOTH"] = "1"

To create a contextual popup menu not visible on the menu bar, just set its Visible property to False.

Menu entries

Menu entries are Menu objects having no child.

Note that Menu controls do not inherit the Control class, and they do not raise any event of the Control class.

The order of menu entries in its popup parent menu follows the order of the creation.

Separators

If the Text property of a menu entry is void, then that menu entry is replaced by a separator.

Useless separators are automatically removed when the popup menu is shown.