src/aoikhotkey/hotkey_manager.py
def _key_dn_hdlr(self, event, mouse_wm=False):
        """
        Key-down event handler.

        :param event: Event object.

        :param mouse_wm: Whether is handler for mouse wheel or mouse move \
            events.

        :return: Whether propagate the event.
        """
        # If given event is mouse event
        if 'mouse' in event.MessageName:
            # Get the mouse event's virtual key
            vk = event.Message

            # 4BIVS
            # If the virtual key is mouse wheel
            if vk == VK_MOUSE_WHEEL:
                # If mouse wheel is scrolling up
                if event.Wheel > 0:
                    # Use wheel-up extended virtual key
                    vk = EVK_MOUSE_WHEEL_UP

                # If mouse wheel is scrolling down
                elif event.Wheel < 0:
                    # Use wheel-down extended virtual key
                    vk = EVK_MOUSE_WHEEL_DOWN

                # If mouse wheel is not scrolling up or down
                else:
                    # Raise error
                    assert 0, event.Wheel

        # If given event is not mouse event
        else:
            # If the platform is Linux,
            # it means the event object's `Key` field contains the key name but
            # `KeyID` field not contains virtual key.
            if IS_LINUX:
                # Convert the key name to virtual key
                event.KeyID = MAP_X11_NAME_TO_WIN_VK.get(event.Key, 0)

            # Get the event's virtual key
            vk = event.KeyID

        # Remove the virtual key from the currently down list to avoid adding
        # duplicate below
        self._vk_down_remove(vk)

        # Remove outdated virtual keys from currently down list
        self._vk_down_remove_outdated()

        # Add the virtual key to the currently down list
        self._vk_down_add(vk)

        # Whether propagate the event.
        # None means use the default.
        propagate = None

        # If event function mask is enabled
        if self._emask & EMASK_V_EFUNC:
            # Call all event functions
            propagate = self._efunc_call_all(event, propagate=propagate)

        # Whether hotkey is found
        hotkey_is_found = False

        # If propagation is not stopped,
        # and hotkey function mask is enabled.
        if (propagate is not False) and (self._emask & EMASK_V_HOTKEY):
            # Find and call hotkey function
            hotkey_is_found, propagate = self._hotkey_find_and_call(
                hotkey=self.vk_down_list(),
                hotkey_type=HOTKEY_TYPE_V_DN,
                event=event,
                propagate=propagate,
            )

        # If is not mouse wheel or mouse move event handler,
        # and hotkey is not found,
        # and propagation is not stopped,
        # and key-sequence function mask is enabled.
        if (not mouse_wm) \
                and (not hotkey_is_found) \
                and (propagate is not False) \
                and (self._emask & EMASK_V_HOTSEQ):
            # Find and call key-sequence function
            hotkey_is_found, propagate = self._hotseq_find_and_call(
                vk=vk, event=event, propagate=propagate
            )

        # If is mouse wheel or mouse move event handler
        if mouse_wm:
            # Remove the mouse event's virtual key because it has no
            # corresponding up event
            self._vk_down_remove(vk)

        # Decide whether propagate the event
        propagate = (not hotkey_is_found) or (propagate is True)

        # Return whether propagate the event
        return propagate

        Key-down event handler.

        :param event: Event object.

        :param mouse_wm: Whether is handler for mouse wheel or mouse move \
            events.

        :return: Whether propagate the event.
        
Key-down event handler.
Key - down event handler .
def _key_dn_hdlr(self, event, mouse_wm=False):
        if 'mouse' in event.MessageName:
            vk = event.Message
            if vk == VK_MOUSE_WHEEL:
                if event.Wheel > 0:
                    vk = EVK_MOUSE_WHEEL_UP
                elif event.Wheel < 0:
                    vk = EVK_MOUSE_WHEEL_DOWN
                else:
                    assert 0, event.Wheel
        else:
            if IS_LINUX:
                event.KeyID = MAP_X11_NAME_TO_WIN_VK.get(event.Key, 0)
            vk = event.KeyID
        self._vk_down_remove(vk)
        self._vk_down_remove_outdated()
        self._vk_down_add(vk)
        propagate = None
        if self._emask & EMASK_V_EFUNC:
            propagate = self._efunc_call_all(event, propagate=propagate)
        hotkey_is_found = False
        if (propagate is not False) and (self._emask & EMASK_V_HOTKEY):
            hotkey_is_found, propagate = self._hotkey_find_and_call(
                hotkey=self.vk_down_list(),
                hotkey_type=HOTKEY_TYPE_V_DN,
                event=event,
                propagate=propagate,
            )
        if (not mouse_wm) \
                and (not hotkey_is_found) \
                and (propagate is not False) \
                and (self._emask & EMASK_V_HOTSEQ):
            hotkey_is_found, propagate = self._hotseq_find_and_call(
                vk=vk, event=event, propagate=propagate
            )
        if mouse_wm:
            self._vk_down_remove(vk)
        propagate = (not hotkey_is_found) or (propagate is True)
        return propagate
def _key_dn_hdlr ( self , event , mouse_wm = False ) : if 'mouse' in event . MessageName : vk = event . Message if vk == VK_MOUSE_WHEEL : if event . Wheel > 0 : vk = EVK_MOUSE_WHEEL_UP elif event . Wheel < 0 : vk = EVK_MOUSE_WHEEL_DOWN else : assert 0 , event . Wheel else : if IS_LINUX : event . KeyID = MAP_X11_NAME_TO_WIN_VK . get ( event . Key , 0 ) vk = event . KeyID self . _vk_down_remove ( vk ) self . _vk_down_remove_outdated ( ) self . _vk_down_add ( vk ) propagate = None if self . _emask & EMASK_V_EFUNC : propagate = self . _efunc_call_all ( event , propagate = propagate ) hotkey_is_found = False if ( propagate is not False ) and ( self . _emask & EMASK_V_HOTKEY ) : hotkey_is_found , propagate = self . _hotkey_find_and_call ( hotkey = self . vk_down_list ( ) , hotkey_type = HOTKEY_TYPE_V_DN , event = event , propagate = propagate , ) if ( not mouse_wm ) and ( not hotkey_is_found ) and ( propagate is not False ) and ( self . _emask & EMASK_V_HOTSEQ ) : hotkey_is_found , propagate = self . _hotseq_find_and_call ( vk = vk , event = event , propagate = propagate ) if mouse_wm : self . _vk_down_remove ( vk ) propagate = ( not hotkey_is_found ) or ( propagate is True ) return propagate
Key-down event handler.
Key - down event handler .
"""
        Key-down event handler.

        :param event: Event object.

        :param mouse_wm: Whether is handler for mouse wheel or mouse move \
            events.

        :return: Whether propagate the event.
        """ # If given event is mouse event # Get the mouse event's virtual key # 4BIVS # If the virtual key is mouse wheel # If mouse wheel is scrolling up # Use wheel-up extended virtual key # If mouse wheel is scrolling down # Use wheel-down extended virtual key # If mouse wheel is not scrolling up or down # Raise error # If given event is not mouse event # If the platform is Linux, # it means the event object's `Key` field contains the key name but # `KeyID` field not contains virtual key. # Convert the key name to virtual key # Get the event's virtual key # Remove the virtual key from the currently down list to avoid adding # duplicate below # Remove outdated virtual keys from currently down list # Add the virtual key to the currently down list # Whether propagate the event. # None means use the default. # If event function mask is enabled # Call all event functions # Whether hotkey is found # If propagation is not stopped, # and hotkey function mask is enabled. # Find and call hotkey function # If is not mouse wheel or mouse move event handler, # and hotkey is not found, # and propagation is not stopped, # and key-sequence function mask is enabled. # Find and call key-sequence function # If is mouse wheel or mouse move event handler # Remove the mouse event's virtual key because it has no # corresponding up event # Decide whether propagate the event # Return whether propagate the event
Whether propagate the event.
Whether propagate the event .
self
event
None
mouse_wm
Whether is handler for mouse wheel or mouse move \
events.
Whether is handler for mouse wheel or mouse move \ events .