User Tools

Site Tools


DzPopupMenu

Script wrapper for a popup QMenu.

More...

Inherits :

Properties

Constructors

DAZ Script
DzPopupMenu ( DzWidget parent )

Methods

DAZ Script
voidclear ()
BooleanconnectItem ( Number id, Object receiver, String member )
BooleanconnectItem ( Number id, Object thisObject, Function functionRef )
BooleandisconnectItem ( Number id, Object receiver, String member )
BooleandisconnectItem ( Number id, Object thisObject, Function functionRef )
Numberexec ()
Numberexec ( Point pos, Number indexAtPoint )
NumberidAt ( Number index )
NumberidAt ( Point pos )
NumberinsertItem ( Pixmap pixmap, String text, Number id=-1, Number index=-1 )
NumberinsertPixmapItem ( Pixmap pixmap, Number id=-1, Number index=-1 )
NumberinsertPixmapSubmenuItem ( Pixmap pixmap, DzPopupMenu popup, Number id=-1, Number index=-1 )
NumberinsertSeparator ( Number index=-1 )
NumberinsertSubmenuItem ( Pixmap pixmap, String text, DzPopupMenu popup, Number id=-1, Number index=-1 )
NumberinsertTextItem ( String text, Number id=-1, Number index=-1 )
NumberinsertTextSubmenuItem ( String text, DzPopupMenu popup, Number id=-1, Number index=-1 )
BooleanisItemCheckable ( Number id )
BooleanisItemChecked ( Number id )
BooleanisItemEnabled ( Number id )
BooleanisItemVisible ( Number id )
NumberitemParameter ( Number id )
NumbernumItems ()
Pixmappixmap ( Number id )
voidpopup ( Point pos, Number indexAtPoint )
voidremoveItem ( Number id )
voidremoveItemAt ( Number index )
voidsetActiveItem ( Number id )
voidsetItemCheckable ( Number id, Boolean yesNo )
voidsetItemChecked ( Number id, Boolean yesNo )
voidsetItemEnabled ( Number id, Boolean yesNo )
BooleansetItemParameter ( Number id, Number param )
voidsetItemVisible ( Number id, Boolean yesNo )
voidsetPixmap ( Number id, Pixmap pixmap )
voidsetText ( Number id, String text )
voidsetWhatsThis ( Number id, String text )
Stringtext ( Number id )
StringwhatsThis ( Number id )
Deprecated
NumberinsertTearOffHandle ()
NumberinsertItem ( String text, Number id=-1, Number index=-1 )
NumberinsertItem ( Pixmap pixmap, Number id=-1, Number index=-1 )
NumberinsertItem ( String text, DzPopupMenu popup, Number id=-1, Number index=-1 )
NumberinsertItem ( Pixmap pixmap, DzPopupMenu popup, Number id=-1, Number index=-1 )
voidchangeItem ( Number id, String text )
voidchangeItem ( Number id, Pixmap pixmap )
voidupdateItem ( Number id )

Signals

voidaboutToHide ()
voidaboutToShow ()
voidactivated ( Number id )
voidhighlighted ( Number id )

Detailed Description

Provides a menu widget for use in context menus and other popup menus.

A menu consists of a list of items. There are three kinds of items: separators, items that show a submenu, and items that perform an action.

Submenu items and action items have an identifier (id) and a position (index). Separators have a position (index) and a common identifier (-1).

Separators are inserted with insertSeparator(). Submenus are inserted with insertSubmenuItem(), insertTextSubmenuItem(), or insertPixmapSubmenuItem(). All other items are considered action items, and are inserted with insertItem(), insertTextItem() or insertPixmapItem().

Submenu items and action items can have text, a pixmap, or both.

Clearing an entire menu is accomplished with clear() and removing individual items is accomplished with removeItem() or removeItemAt().

To make a menu visible on the screen, use exec() or popup() - do not use show().

Properties


Boolean : checkable

Holds whether or not the display of check marks on menu items is enabled. When true, the display of check marks on menu items is enabled. Checking is always enabled when in Windows-style.


Boolean : tearOff

Holds whether or not the menu supports being torn off. When true, the menu contains a special tear-off item (often shown as a dashed line at the top of the menu) that creates a copy of the menu when it is triggered.

This “torn-off” copy lives in a separate window. It contains the same menu items as the original menu, with the exception of the tear-off handle.

Constructors


DzPopupMenu( DzWidget parent )

Creates a popup menu as a child of the given parent widget.

Parameter(s):

  • parent - The widget parent for the popup menu.

Methods


void : clear()

Removes all menu items.


Boolean : connectItem( Number id, Object receiver, String member )

Connects the menu item with the specified identifier to a function.

Parameter(s):

  • id - The identifier of the menu item to connect to.
  • receiver - The object that will receive the signal. Prior to 4.15.0.24, this must be a QObject (or derived).
  • function - The name of the function on receiver to execute when the menu item is activated. Prior to 4.15.0.24, the signature of this function must have no parameters, or a single parameter of the 'int' type.

Return Value:

  • true if the connection is successfully established, otherwise false.

Boolean : connectItem( Number id, Object thisObject, Function functionRef )

Connects the menu item with the specified identifier to a function.

Parameter(s):

  • id - The identifier of the menu item to connect to.
  • thisObject - The object to bind to 'this' in the scope of functionRef if functionRef is a script-defined Function. If functionRef is a function on a QObject, this argument is not used.
  • functionRef - The function to execute when the menu item is activated.

Return Value:

  • true if the connection is successfully established, otherwise false.

Since:

  • 4.15.0.24

Boolean : disconnectItem( Number id, Object receiver, String member )

Disconnects the menu item with the specified identifier from a function.

Parameter(s):

  • id - The identifier of the menu item to disconnect from.
  • receiver - The object that is receiving the signal. Prior to 4.15.0.24, this must be a QObject (or derived).
  • function - The name of the function on receiver to disconnect from.

Return Value:

  • true if the connection is successfully removed, otherwise false.

Attention:

  • All connections are automatically removed when this menu is destroyed.

Boolean : disconnectItem( Number id, Object thisObject, Function functionRef )

Disconnects the menu item with the specified identifier from a function.

Parameter(s):

  • id - The identifier of the menu item to disconnect from.
  • thisObject - The object bound to 'this' in the scope of functionRef if functionRef is a script-defined Function. If functionRef is a function on a QObject, this argument is not used.
  • functionRef - The function to disconnect from.

Return Value:

  • true if the connection is successfully removed, otherwise false.

Attention:

  • All connections are automatically removed when this menu is destroyed.

Since:

  • 4.15.0.24

Number : exec()

Executes this menu synchronously. In most situations you will want to specify the position yourself, for example at the current mouse position.

Return Value:

  • The identifier of the menu item clicked, or -1 if a menu item was not clicked.

Number : exec( Point pos, Number indexAtPoint )

Executes this menu synchronously. Opens the popup menu so that the item number indexAtPoint will be at the specified global position pos.

Parameter(s):

  • pos - The global position to popup the menu.
  • indexAtPoint - The index of the menu item to position at pos.

Return Value:

  • The identifier of the menu item clicked, or -1 if a menu item was not clicked.

See Also:


Number : idAt( Number index )

Parameter(s):

  • index - The index position to get the identifier for.

Return Value:

  • The identifier for the menu item at the specified index position (if valid), otherwise -1.

Number : idAt( Point pos )

Parameter(s):

  • pos - The position to to check.

Return Value:

  • The identifier of the menu item at the specified index position (if any), otherwise -1.

See Also:


Number : insertItem( Pixmap pixmap, String text, Number id=-1, Number index=-1 )

Inserts a menu item, with a pixamp, and text into this menu.

Parameter(s):

  • pixmap - The pixmap to assign to this menu item.
  • text - The text to assign to the menu item.
  • id - The identifier to assign to the menu item.
  • index - The index position within the menu to insert the item. The item becomes the last menu item if this is a negative value (default).

Return Value:

  • The identifier assigned to the inserted menu item.

Since:

  • 4.15.0.16

Number : insertPixmapItem( Pixmap pixmap, Number id=-1, Number index=-1 )

Inserts a menu item, with a pixmap, into this menu.

Parameter(s):

  • pixmap - The pixmap to assign to the menu item.
  • id - The identifier to assign to the menu item.
  • index - The index position within the menu to insert the item. The item becomes the last menu item if this is a negative value (default).

Return Value:

  • The identifier assigned to the inserted menu item.

Since:

  • 4.15.0.16

Number : insertPixmapSubmenuItem( Pixmap pixmap, DzPopupMenu popup, Number id=-1, Number index=-1 )

Inserts a submenu item, with a pixmap, into this menu.

Parameter(s):

  • pixmap - The pixmap to assign to the menu item.
  • popup - The menu to popup when this menu item is hovered over.
  • id - The identifier to assign to the menu item.
  • index - The index position within the menu to insert the item. The item becomes the last menu item if this is a negative value (default).

Return Value:

  • The identifier assigned to the inserted menu item.

Since:

  • 4.15.0.16

Number : insertSeparator( Number index=-1 )

Inserts a separator at the specified index position.

Parameter(s):

  • index - The index position within the menu to insert the separator. The separator becomes the last menu item if this is a negative value (default).

Return Value:

  • The identifier assigned to the inserted menu item - i.e., -1.

Number : insertSubmenuItem( Pixmap pixmap, String text, DzPopupMenu popup, Number id=-1, Number index=-1 )

Inserts a submenu item, with a pixmap and text, into this menu.

Parameter(s):

  • pixmap - The pixmap to assign to the menu item.
  • text - The text to assign to the menu item.
  • popup - The menu to popup when this menu item is hovered over.
  • id - The identifier to assign to the menu item.
  • index - The index position within the menu to insert the item. The item becomes the last menu item if this is a negative value (default).

Return Value:

  • The identifier assigned to the inserted menu item.

Since:

  • 4.15.0.16

Number : insertTextItem( String text, Number id=-1, Number index=-1 )

Inserts a menu item, with text, into this menu.

Parameter(s):

  • text - The text to assign to the menu item.
  • id - The identifier to assign to the menu item.
  • index - The index position within the menu to insert the item. The item becomes the last menu item if this is a negative value (default).

Return Value:

  • The identifier assigned to the inserted menu item.

Since:

  • 4.15.0.16

Number : insertTextSubmenuItem( String text, DzPopupMenu popup, Number id=-1, Number index=-1 )

Inserts a submenu item, with text, into this menu.

Parameter(s):

  • text - The text to assign to the menu item.
  • popup - The menu to popup when this menu item is hovered over.
  • id - The identifier to assign to the menu item.
  • index - The index position within the menu to insert the item. The item becomes the last menu item if this is a negative value (default).

Return Value:

  • The identifier assigned to the inserted menu item.

Since:

  • 4.15.0.16

Boolean : isItemCheckable( Number id )

Parameter(s):

  • id - The identifier of the menu item to get the checkable state of.

Return Value:

  • true if the menu item with the specified identifier is checkable, otherwise false.

Since:

  • 4.12.1.93

Boolean : isItemChecked( Number id )

Parameter(s):

  • id - The identifier of the menu item to get the checked state of.

Return Value:

  • true if the menu item with the specified identifier is checked, otherwise false.

Boolean : isItemEnabled( Number id )

Parameter(s):

  • id - The identifier of the menu item to get the enabled state of.

Return Value:

  • true if the menu item with the specified identifier is enabled, otherwise false.

Boolean : isItemVisible( Number id )

Parameter(s):

  • id - The identifier of the menu item to get the visible state of.

Return Value:

  • true if the menu item with the specified identifier is visible, otherwise false.

Number : itemParameter( Number id )

Parameter(s):

  • id - The identifier of the menu item to get the parameter of.

Return Value:

  • The parameter of the activation signal for the menu item specified (if any), otherwise id.

Number : numItems()

Return Value:

  • The number of menu items in this menu.

Since:

  • 4.15.0.16

Pixmap : pixmap( Number id )

Parameter(s):

  • id - The identifier of the menu item to get the pixmap of.

Return Value:

  • The pixmap of the menu item with the specified identifier (if any), otherwise null.

void : popup( Point pos, Number indexAtPoint )

Displays this menu synchronously.

Parameter(s):

  • pos - The global position to popup the menu.
  • indexAtPoint - The index of the menu item to position at pos.

See Also:


void : removeItem( Number id )

Removes the menu item with the specified identifier from the menu.

Parameter(s):

  • id - The identifier of the menu item to remove.

void : removeItemAt( Number index )

Removes the menu item at the specified index position.

Parameter(s):

  • index - The index position of the menu item to remove.

void : setActiveItem( Number id )

Sets the currently active item to id and repaints as necessary.


void : setItemCheckable( Number id, Boolean yesNo )

Sets the checkable state of the menu item with the specified identifier.

Parameter(s):

  • id - The identifier of the menu item to set.
  • yesNo - If true, the item is made checkable.

Since:

  • 4.12.1.93

void : setItemChecked( Number id, Boolean yesNo )

Sets the checked state of the menu item with the specified identifier.

Parameter(s):

  • id - The identifier of the menu item to set.
  • yesNo - If true, the item is checked.

void : setItemEnabled( Number id, Boolean yesNo )

Sets the enabled state of the menu item with the specified identifier.

Parameter(s):

  • id - The identifier of the menu item to set.
  • yesNo - If true, the item is enabled.

Boolean : setItemParameter( Number id, Number param )

Sets the parameter of the activation signal for the menu item with the specified identifier.

Parameter(s):

  • id - The identifier of the menu item to set.
  • param - The value to set.

void : setItemVisible( Number id, Boolean yesNo )

Sets the visible state of the menu item with the specified identifier.

Parameter(s):

  • id - The identifier of the menu item to set.
  • yesNo - If true, the item is made visible.

void : setPixmap( Number id, Pixmap pixmap )

Sets the pixmap of the menu item with the specified identifier.

Parameter(s):

  • id - The identifier of the menu item to change.
  • pixmap - The pixmap to set.

Attention:

  • If the item has text assigned, the text remains unchanged.

Since:

  • 4.15.0.16

void : setText( Number id, String text )

Sets the text of the menu item with the specified identifier.

Parameter(s):

  • id - The identifier of the menu item to change.
  • text - The text to set.

Attention:

  • If the item has a pixmap assigned, the pixmap remains unchanged.

Since:

  • 4.15.0.16

void : setWhatsThis( Number id, String text )

Sets the “What's This” help text for the menu item with the specified identifier.

Parameter(s):

  • id - The identifier of the menu item to set the “What's This” help text for.
  • text - The text to set.

String : text( Number id )

Parameter(s):

  • id - The identifier of the menu item to get the text of.

Return Value:

  • The text of the menu item with the specified identifier (if any), otherwise an empty string.

String : whatsThis( Number id )

Parameter(s):

  • id - The identifier of the menu item to get the “What's This” help text for.

Return Value:

  • The “What's This” help text for the item with the specified identifier (if any), otherwise an empty string.

Number : insertTearOffHandle()

Deprecated

Exists only to keep old code working. Do not use in new code. Use the tearOff property instead.


Number : insertItem( String text, Number id=-1, Number index=-1 )

Deprecated

Exists only to keep old code working. Do not use in new code. Use insertTextItem() instead.


Number : insertItem( Pixmap pixmap, Number id=-1, Number index=-1 )

Deprecated

Exists only to keep old code working. Do not use in new code. Use insertPixmapItem() instead.


Number : insertItem( String text, DzPopupMenu popup, Number id=-1, Number index=-1 )

Deprecated

Exists only to keep old code working. Do not use in new code. Use insertTextSubmenuItem() instead.


Number : insertItem( Pixmap pixmap, DzPopupMenu popup, Number id=-1, Number index=-1 )

Deprecated

Exists only to keep old code working. Do not use in new code. Use insertPixmapSubmenuItem() instead.


void : changeItem( Number id, String text )

Deprecated

Exists only to keep old code working. Do not use in new code. Use setText() instead.


void : changeItem( Number id, Pixmap pixmap )

Deprecated

Exists only to keep old code working. Do not use in new code. Use setPixmap() instead.


void : updateItem( Number id )

Deprecated

Exists only to keep old code working. Do not use in new code. Does nothing.

Signals


void : aboutToHide()

Signature:“aboutToHide()”

This signal is emitted just before the popup menu is hidden after it has been displayed.


void : aboutToShow()

Signature:“aboutToShow()”

This signal is emitted just before the popup menu is displayed. You can connect it to any slot that sets up the menu contents (e.g. to ensure that the right items are enabled).


void : activated( Number id )

Signature:“activated(int)”

This signal is emitted when a menu item is selected.

Parameter(s):

  • id - The id of the selected item.

void : highlighted( Number id )

Signature:“highlighted(int)”

Emitted when a menu item is highlighted.

Parameter(s):

  • id - The id of the highlighted item.