Class Shortcuts

class ooodev.gui.menu.Shortcuts(app='', lo_inst=None)[source]

Class for manager shortcuts.

Parameters:
__init__(app='', lo_inst=None)[source]

Constructor

Parameters:
  • app (str | Service, optional) – App Name such as Service.CALC. Defaults to “”. If no app is provided, the global shortcuts will be used.

  • lo_inst (LoInst | None) –

Hint

  • Service is an enum and can be imported from ooodev.loader.inst.service

classmethod from_key_event(key_event)[source]

Convert from KeyEvent to string shortcut

Return type:

str

Parameters:

key_event (KeyEvent) –

get_all()[source]

Get all events key.

Returns:

List of tuples with shortcut and command.

Return type:

List[Tuple[str, str]]

get_by_command(command)[source]

Get shortcuts by command.

Parameters:

command (str | dict) – Command to search, ‘UNOCOMMAND’ or dict with macro info.

Returns:

List of shortcuts or empty list of not found.

Return type:

List[str]

get_by_key_event(key_event)[source]

Get command by key event

Return type:

str

Parameters:

key_event (KeyEvent) –

get_by_shortcut(shortcut)[source]

Get command by shortcut

Return type:

str

Parameters:

shortcut (str) –

get_shortcut(key)[source]

Get shortcut for key event.

Parameters:

key (KeyEvent) – Key event

Returns:

Shortcut like Shift+Ctrl+Alt+LETTER

Return type:

str

classmethod get_url_script(command)[source]

Get uno command or url for macro.

Parameters:

command (str | CommandDict) – Command to search, ‘UNOCOMMAND’ or dict with macro info.

Returns:

Url for macro or uno command or custom command.

Return type:

str

Note

If command is passed in a a string and it starts with .custom: then it will be returned with the .custom: prefix dropped.

The .custom: prefix is used to indicate that the command is a custom command and can be used in a menu callback to capture user clicks.

remove_by_command(command, save=False)[source]

Remove by shortcut.

Parameters:
  • command (str | CommandDict) – Command to remove, ‘UNOCOMMAND’ or dict with macro info.

  • save (bool, optional) – Save configuration causing it to persist. Defaults to False.

remove_by_shortcut(shortcut, save=False)[source]

Remove by shortcut

Parameters:
  • shortcut (str) – Shortcut like Shift+Ctrl+Alt+LETTER

  • save (bool, optional) – Save configuration causing it to persist. Defaults to False.

Returns:

True if removed successfully

Return type:

bool

reset()[source]

Reset configuration

Return type:

None

set(shortcut, command, save=True)[source]

Set shortcut to command

Parameters:
  • shortcut (str) – Shortcut like Shift+Ctrl+Alt+LETTER

  • command (str | CommandDict) – Command to assign, ‘UNOCOMMAND’ or dict with macro info.

  • save (bool, optional) – Save configuration causing it to persist. Defaults to True.

Returns:

True if set successfully

Return type:

bool

classmethod to_key_event(shortcut)[source]

Convert from string shortcut (Shift+Ctrl+Alt+LETTER) to KeyEvent

Return type:

KeyEvent | None

Parameters:

shortcut (str) –

COMBINATIONS = {0: '', 1: 'shift', 2: 'ctrl', 3: 'shift+ctrl', 4: 'alt', 5: 'shift+alt', 6: 'ctrl+alt', 7: 'shift+ctrl+alt', 8: 'ctrlmac', 9: 'shift+ctrlmac', 10: 'ctrl+ctrlmac', 11: 'shift+ctrl+ctrlmac', 12: 'alt+ctrlmac', 13: 'shift+alt+ctrlmac', 14: 'ctrl+alt+ctrlmac', 15: 'shift+ctrl+alt+ctrlmac'}
KEYS: Dict[int, str] = {}

The dictionary Keys are the integer values of the keys and the values are the key names.

MODIFIERS = {'alt': 4, 'ctrl': 2, 'ctrlmac': 8, 'shift': 1}