Beispiel #1
0
 def EventCharHook( self, event ):
     
     ( modifier, key ) = ClientData.ConvertKeyEventToSimpleTuple( event )
     
     if key == wx.WXK_ESCAPE:
         
         self.Close()
         
     else:
         
         event.Skip()
Beispiel #2
0
    def EventKeyDown(self, event):

        (modifier, key) = ClientData.ConvertKeyEventToSimpleTuple(event)

        if key in CC.DELETE_KEYS:

            if self._delete_key_callback is not None:

                self._delete_key_callback()

        elif key in (ord('A'), ord('a')) and modifier == wx.ACCEL_CTRL:

            self.SelectAll()

        else:

            event.Skip()
Beispiel #3
0
    def EventCharHook(self, event):

        HG.client_controller.ResetIdleTimer()

        (modifier, key) = ClientData.ConvertKeyEventToSimpleTuple(event)

        if key in (wx.WXK_INSERT, wx.WXK_NUMPAD_INSERT):

            self._intercept_key_events = not self._intercept_key_events

            self._UpdateBackgroundColour()

        elif key == wx.WXK_SPACE and event.RawControlDown(
        ):  # this is control, not command on os x, for which command+space does some os stuff

            self._ScheduleListRefresh(0.0)

        elif self._intercept_key_events:

            if key in (ord('A'), ord('a')) and modifier == wx.ACCEL_CTRL:

                event.Skip()

            elif key in (wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER
                         ) and self._ShouldTakeResponsibilityForEnter():

                self._TakeResponsibilityForEnter()

            elif key in (wx.WXK_UP, wx.WXK_NUMPAD_UP, wx.WXK_DOWN,
                         wx.WXK_NUMPAD_DOWN
                         ) and self._text_ctrl.GetValue() == '' and len(
                             self._dropdown_list) == 0:

                if key in (wx.WXK_UP, wx.WXK_NUMPAD_UP):

                    new_event = SelectUpEvent(-1)

                elif key in (wx.WXK_DOWN, wx.WXK_NUMPAD_DOWN):

                    new_event = SelectDownEvent(-1)

                wx.PostEvent(self.GetEventHandler(), new_event)

            elif key in (wx.WXK_PAGEDOWN, wx.WXK_NUMPAD_PAGEDOWN,
                         wx.WXK_PAGEUP, wx.WXK_NUMPAD_PAGEUP
                         ) and self._text_ctrl.GetValue() == '' and len(
                             self._dropdown_list) == 0:

                if key in (wx.WXK_PAGEUP, wx.WXK_NUMPAD_PAGEUP):

                    new_event = ShowPreviousEvent(-1)

                elif key in (wx.WXK_PAGEDOWN, wx.WXK_NUMPAD_PAGEDOWN):

                    new_event = ShowNextEvent(-1)

                wx.PostEvent(self.GetEventHandler(), new_event)

            else:

                # Don't say process/postevent here--it duplicates the event processing at higher levels, leading to 2 x F9, for instance
                self._dropdown_list.EventCharHook(
                    event
                )  # this typically skips the event, letting the text ctrl take it

        else:

            event.Skip()
Beispiel #4
0
    def EventCharHook(self, event):

        HG.client_controller.ResetIdleTimer()

        (modifier, key) = ClientData.ConvertKeyEventToSimpleTuple(event)

        if key in (wx.WXK_INSERT, wx.WXK_NUMPAD_INSERT):

            self._intercept_key_events = not self._intercept_key_events

            self._UpdateBackgroundColour()

        elif key == wx.WXK_SPACE and event.RawControlDown(
        ):  # this is control, not command on os x, for which command+space does some os stuff

            self._UpdateList()

            self._lag_timer.Stop()

        elif self._intercept_key_events:

            if key in (ord('A'), ord('a')) and modifier == wx.ACCEL_CTRL:

                event.Skip()

            elif key in (wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER
                         ) and self._ShouldTakeResponsibilityForEnter():

                self._TakeResponsibilityForEnter()

            elif key in (wx.WXK_UP, wx.WXK_NUMPAD_UP, wx.WXK_DOWN,
                         wx.WXK_NUMPAD_DOWN
                         ) and self._text_ctrl.GetValue() == '' and len(
                             self._dropdown_list) == 0:

                if key in (wx.WXK_UP, wx.WXK_NUMPAD_UP):

                    id = ClientCaches.MENU_EVENT_ID_TO_ACTION_CACHE.GetTemporaryId(
                        'select_up')

                elif key in (wx.WXK_DOWN, wx.WXK_NUMPAD_DOWN):

                    id = ClientCaches.MENU_EVENT_ID_TO_ACTION_CACHE.GetTemporaryId(
                        'select_down')

                new_event = wx.CommandEvent(
                    commandType=wx.wxEVT_COMMAND_MENU_SELECTED, winid=id)

                self.ProcessEvent(new_event)

            elif key in (wx.WXK_PAGEDOWN, wx.WXK_NUMPAD_PAGEDOWN,
                         wx.WXK_PAGEUP, wx.WXK_NUMPAD_PAGEUP
                         ) and self._text_ctrl.GetValue() == '' and len(
                             self._dropdown_list) == 0:

                if key in (wx.WXK_PAGEUP, wx.WXK_NUMPAD_PAGEUP):

                    id = ClientCaches.MENU_EVENT_ID_TO_ACTION_CACHE.GetTemporaryId(
                        'canvas_show_previous')

                elif key in (wx.WXK_PAGEDOWN, wx.WXK_NUMPAD_PAGEDOWN):

                    id = ClientCaches.MENU_EVENT_ID_TO_ACTION_CACHE.GetTemporaryId(
                        'canvas_show_next')

                new_event = wx.CommandEvent(
                    commandType=wx.wxEVT_COMMAND_MENU_SELECTED, winid=id)

                self.ProcessEvent(new_event)

            else:

                # Don't say processevent here--it duplicates the event processing at higher levels, leading to 2 x F9, for instance
                self._dropdown_list.EventCharHook(
                    event
                )  # this typically skips the event, letting the text ctrl take it

        else:

            event.Skip()