ooodev.adapter.awt.popup_menu_partial module

class ooodev.adapter.awt.popup_menu_partial.PopupMenuPartial(component, interface=com.sun.star.awt.XPopupMenu)[source]

Bases: MenuPartial

Partial Class for XPopupMenu.

Parameters:
  • component (XPopupMenu) –

  • interface (UnoInterface | None) –

__init__(component, interface=com.sun.star.awt.XPopupMenu)[source]

Constructor

Parameters:
  • component (XPopupMenu) – UNO Component that implements com.sun.star.awt.XPopupMenu interface.

  • interface (UnoInterface, optional) – The interface to be validated. Defaults to XPopupMenu.

Return type:

None

check_item(menu_id, check=True)[source]

Sets the state of the item to be checked or unchecked.

Parameters:
  • menu_id (int) – The item identifier.

  • check (bool, optional) – The state of the item. Defaults to True.

Return type:

None

end_execute()[source]

Ends the execution of the PopupMenu.

XPopupMenu.execute() will then return 0.

Return type:

None

execute(parent, position, direction=0)[source]

Executes the popup menu and returns the selected item or 0, if cancelled.

Parameters:
  • parent (XWindowPeer) – The parent window.

  • position (Rectangle) – The position of the popup menu.

  • direction (int | PopupMenuDirectionEnum, optional) – The direction of the popup menu. Defaults to 0.

Returns:

The selected item or 0 if cancelled.

Return type:

int

Hint

  • PopupMenuDirectionEnum is an enum that can be imported from ooo.dyn.awt.popup_menu_direction.

Note

direction values:

  • EXECUTE_DEFAULT = 0

  • EXECUTE_DOWN = 1

  • EXECUTE_UP = 2

  • EXECUTE_LEFT = 4

  • EXECUTE_RIGHT = 8

get_accelerator_key_event(menu_id)[source]

Gets the KeyEvent for the menu item.

The KeyEvent is only used as a container to transport the shortcut information, so that in this case com.sun.star.lang.EventObject.Source is None.

Return type:

KeyEvent

Parameters:

menu_id (int) –

get_default_item()[source]

Gets the menu default item.

Return type:

int

get_item_image(menu_id)[source]

Gets the image for the menu item.

Return type:

XGraphic

Parameters:

menu_id (int) –

insert_separator(item_pos)[source]

Inserts a separator at the specified position.

Return type:

None

Parameters:

item_pos (int) –

is_in_execute()[source]

Queries if the PopupMenu is being.

Returns True only if the PopupMenu is being executed as a result of invoking`` XPopupMenu.execute()``; that is, for a PopupMenu activated by a MenuBar item, this methods returns False.

Return type:

bool

is_item_checked(menu_id)[source]

Gets whether the item is checked or unchecked.

Return type:

bool

Parameters:

menu_id (int) –

set_accelerator_key_event(menu_id, key_event)[source]

Sets the KeyEvent for the menu item.

The KeyEvent is only used as a container to transport the shortcut information, this methods only draws the text corresponding to this keyboard shortcut. The client code is responsible for listening to keyboard events (typically done via XUserInputInterception), and dispatch the respective command.

Return type:

None

Parameters:
  • menu_id (int) –

  • key_event (com.sun.star.awt.KeyEvent) –

set_default_item(menu_id)[source]

Sets the menu default item.

Return type:

None

Parameters:

menu_id (int) –

set_item_image(menu_id, graphic, scale)[source]

Sets the image for the menu item.

Return type:

None

Parameters:
  • menu_id (int) –

  • graphic (com.sun.star.graphic.XGraphic) –

  • scale (bool) –