Exemplo n.º 1
0
    def OnKey(self, event):
        logger.debug('onkey')
        keycode = event.GetKeyCode()
        keyname = keyMap.get(keycode, None)

        if keycode == wx.WXK_BACK:
            self.log.write(
                "OnKeyDown: HAHAHAHA! I Vetoed Your Backspace! HAHAHAHA\n")
            return

        if keyname is None:
            if "unicode" in wx.PlatformInfo:
                keycode = event.GetUnicodeKey()
                if keycode <= 127:
                    keycode = event.GetKeyCode()
                keyname = "\"" + event.GetUnicodeKey() + "\""
                if keycode < 27:
                    keyname = "Ctrl-%s" % chr(ord('A') + keycode - 1)

            elif keycode < 256:
                if keycode == 0:
                    keyname = "NUL"
                elif keycode < 27:
                    keyname = "Ctrl-%s" % chr(ord('A') + keycode - 1)
                else:
                    keyname = "\"%s\"" % chr(keycode)
            else:
                keyname = "unknown (%s)" % keycode

        self.log.write("OnKeyDown: You Pressed '" + keyname + "'\n")

        event.Skip()
Exemplo n.º 2
0
    def GetKeyPress(self, evt):
        keycode = evt.GetKeyCode()
        keyname = keyMap.get(keycode, None)
        modifiers = ""
        for mod, ch in ((evt.GetKeyEvent().ControlDown(), 'Ctrl+'),
                        (evt.GetKeyEvent().AltDown(), 'Alt+'),
                        (evt.GetKeyEvent().ShiftDown(), 'Shift+'),
                        (evt.GetKeyEvent().MetaDown(), 'Meta+')):
            if mod:
                modifiers += ch
            else:
                modifiers += '-'
#         if keyname is None:
#             if keycode < 256:
#                 if keycode == 0:
#                     keyname = "NUL"
#                 elif keycode < 27:
#                     char_keycode=chr(ord('A') + keycode-1)
#                     keyname = f"Ctrl-{char_keycode}" % (ord('A') + keycode - 1)
#                 else:
#                     keyname = u"\"%s\"" % keycode
#             else:
#                 keyname = u"(%s)" % keycode
        if keyname is None:
            if keycode == 0:
                keyname = "NUL"
            elif  27 < keycode < 256  :
                keyname = chr(keycode)
            elif  keycode < 27 :
                keyname = chr(ord('A') + keycode - 1)
                logger.debug(keyname)
            else:
                keyname = f"({chr(keycode)})unknown"
        logger.debug(f'modifiers:{modifiers},keyname:{keyname}')
        return modifiers + keyname
Exemplo n.º 3
0
 def onTreeKeyDown(self, event):
     logger.debug('onTreeKeyDown')
     keypress = self.GetKeyPress(event)
     keycode = event.GetKeyCode()
     keyname = keyMap.get(keycode, None)
     logger.debug('onTreeKeyDown keycode: %s  keyname:%s keypress: %s', keycode, keyname, keypress)
     logger.debug(keypress == 'WXK_F2')
     
     if keypress == 'Ctrl+C':
         self.onTreeCopy(event)
     elif keypress == 'WXK_F2':
         self.onF2KeyPress(event)
     elif keypress == 'WXK_DELETE':
         self.onDeleteKeyPress(event)
     event.Skip()
Exemplo n.º 4
0
 def GetKeyPress(self, evt):
     keycode = evt.GetKeyCode()
     keyname = keyMap.get(keycode, None)
     modifiers = ""
     for mod, ch in ((evt.GetKeyEvent().ControlDown(), 'Ctrl+'),
                     (evt.GetKeyEvent().AltDown(), 'Alt+'),
                     (evt.GetKeyEvent().ShiftDown(), 'Shift+'),
                     (evt.GetKeyEvent().MetaDown(), 'Meta+')):
         if mod:
             modifiers += ch
 
     if keyname is None:
         if 27 < keycode < 256:
             keyname = chr(keycode)
         else:
             keyname = "(%s)unknown" % keycode
     return modifiers + keyname
Exemplo n.º 5
0
    def onSelectionChange(self, event):
        logger.debug(f'onSelectionChange {self}')
#         self.LogKeyEvent('KeyDown', event.GetKeyEvent())
        keypress = self.GetKeyPress(event)
        keycode = event.GetKeyCode()
        keyname = keyMap.get(keycode, None)
        logger.debug(f'onSelectionChange keycode: {keycode}  keypress: {keypress} keyname: {keyname}')

        self.GetSelectedFiles()
#         logger.debug(keypress == 'WXK_F2')
#
# #         if keypress == 'Ctrl+C':
# #             pass
# #             self.onTreeCopy(event)
#         if keypress == 'WXK_F2':
#             self.onF2KeyPress(event)
#         elif keypress == 'WXK_DELETE':
#             self.onDeleteKeyPress(event)
        event.Skip()
Exemplo n.º 6
0
    def onTreeKeyDown(self, event):
        logger.debug(f'onTreeKeyDown {self}')
#         self.LogKeyEvent('KeyDown', event.GetKeyEvent())
        keypress = self.GetKeyPress(event)
        keycode = event.GetKeyCode()
        keyname = keyMap.get(keycode, None)
        logger.debug(f'onTreeKeyDown keycode: {keycode}  keypress: {keypress} keyname: {keyname}')
        nodes = self.GetSelections()
        files = [ self.GetPyData(node) for node in nodes ]
#         files = self.GetSelectedFiles()
        logger.debug(files)
#         logger.debug(keypress == 'WXK_F2')
#
# #         if keypress == 'Ctrl+C':
# #             pass
# #             self.onTreeCopy(event)
#         if keypress == 'WXK_F2':
#             self.onF2KeyPress(event)
#         elif keypress == 'WXK_DELETE':
#             self.onDeleteKeyPress(event)
        event.Skip()