Source code for ooodev.adapter.awt.menu_events

from __future__ import annotations
from typing import Any, cast, TYPE_CHECKING
from import GenericArgs
from import ListenerEventArgs
from ooodev.utils import gen_util as gUtil
from ooodev.adapter.awt.menu_listener import MenuListener

    from import XMenu
    from ooodev.utils.type_var import EventArgsCallbackT, ListenerEventCallbackT

[docs]def on_lazy_cb(source: Any, event: ListenerEventArgs) -> None: """ 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. Args: source (Any): Expected to be an instance of MenuEvents that is a partial class of a component based class. event (ListenerEventArgs): Event arguments. Returns: None: Warning: This method is intended for internal use only. """ # will only ever fire once if not isinstance(source, MenuEvents): return if not hasattr(source, "component"): return comp = cast("XMenu", source.component) # type: ignore comp.addMenuListener(source.events_listener_menu) event.remove_callback = True