ooodev.adapter.ui.context_menu_interceptor_events module

class ooodev.adapter.ui.context_menu_interceptor_events.ContextMenuInterceptorEvents(component, trigger_args=None, cb=None)[source]

Bases: object

Class for managing Context Menu Interceptor Events.

Parameters:
  • component (XContextMenuInterception) –

  • trigger_args (GenericArgs | None) –

  • cb (ListenerEventCallbackT | None) –

__init__(component, trigger_args=None, cb=None)[source]

Constructor

Parameters:
  • component (XContextMenuInterception) – UNO Component that implements com.sun.star.ui.XContextMenuInterception.

  • trigger_args (GenericArgs, optional) – Args that are passed to events when they are triggered. This only applies if the listener is not passed.

  • cb (ListenerEventCallbackT | None, optional) – Callback that is invoked when an event is added or removed.

Return type:

None

add_event_notify_context_menu_execute(cb)[source]

Adds and registers a listener for an event.

Notifies the interceptor about the request to execute a ContextMenu. The interceptor has to decide whether the menu should be executed with or without being modified or may ignore the call.

The call back event is an instance of GenericArgs[ContextMenuInterceptorEventData].

The callback GenericArgs.event_data will be an instance of ContextMenuInterceptorEventData.

The event_data.action defaults to ContextMenuInterceptorAction.IGNORED and can be modified to change the action. IGNORED in this context means that The next registered XContextMenuInterceptor should be notified.

Return type:

None

Parameters:

cb (Any) –

Hint: - ContextMenuInterceptorAction is an enum that can be imported from ooo.dyn.ui.context_menu_interceptor_action.

Note

Registering an interceptor adds it to the front of the interceptor chain, so that it is called first. The order of removals is arbitrary. It is not necessary to remove the interceptor that registered last.

Each time this method is called, a new listener is created and registered if it does not already exist.

remove_event_notify_context_menu_execute(cb)[source]

Un-registers and removes a listener for an event.

Return type:

None

Parameters:

cb (Any) –

ooodev.adapter.ui.context_menu_interceptor_events.on_lazy_cb(source, event)[source]

Callback that is invoked when an event is added or removed.

This method is generally used to add the listener to the component in a lazy manner. This means this callback will only be called once in the lifetime of the component.

Parameters:
  • source (Any) – Expected to be an instance of ActivationEventEvents that is a partial class of a component based class.

  • event (ListenerEventArgs) – Event arguments.

Return type:

None

Warning

This method is intended for internal use only.