Exemplo n.º 1
0
def ConvertKeyEventToShortcut( event ):
    
    key = event.KeyCode
    
    if ClientData.OrdIsSensibleASCII( key ) or key in CC.wxk_code_string_lookup.keys():
        
        modifiers = []
        
        if event.AltDown():
            
            modifiers.append( CC.SHORTCUT_MODIFIER_ALT )
            
        
        if event.CmdDown():
            
            modifiers.append( CC.SHORTCUT_MODIFIER_CTRL )
            
        
        if event.ShiftDown():
            
            modifiers.append( CC.SHORTCUT_MODIFIER_SHIFT )
            
        
        shortcut = Shortcut( CC.SHORTCUT_TYPE_KEYBOARD, key, modifiers )
        
        if HG.gui_report_mode:
            
            HydrusData.ShowText( 'key event caught: ' + repr( shortcut ) )
            
        
        return shortcut
        
    
    return None
Exemplo n.º 2
0
 def ToString( self ):
     
     components = []
     
     if CC.SHORTCUT_MODIFIER_CTRL in self._modifiers:
         
         components.append( 'ctrl' )
         
     
     if CC.SHORTCUT_MODIFIER_ALT in self._modifiers:
         
         components.append( 'alt' )
         
     
     if CC.SHORTCUT_MODIFIER_SHIFT in self._modifiers:
         
         components.append( 'shift' )
         
     
     if self._shortcut_type == CC.SHORTCUT_TYPE_KEYBOARD:
         
         if self._shortcut_key in CC.wxk_code_string_lookup:
             
             components.append( CC.wxk_code_string_lookup[ self._shortcut_key ] )
             
         elif ClientData.OrdIsAlphaUpper( self._shortcut_key ):
             
             components.append( chr( self._shortcut_key + 32 ) ) # + 32 for converting ascii A -> a
             
         elif ClientData.OrdIsSensibleASCII( self._shortcut_key ):
             
             components.append( chr( self._shortcut_key ) )
             
         else:
             
             components.append( 'unknown key' )
             
         
     elif self._shortcut_type == CC.SHORTCUT_TYPE_MOUSE:
         
         components.append( CC.shortcut_mouse_string_lookup[ self._shortcut_key ] )
         
     
     return '+'.join( components )