Example #1
0
 def _get_symbol_and_modifiers(ev):
     # The unicode char help processing virtual keycodes (see issue 405)
     wchar = c_wchar()
     carbon.GetEventParameter(ev, kEventParamKeyUnicodes,
         typeUnicodeText, c_void_p(), sizeof(wchar), c_void_p(), byref(wchar))
     try:
         wchar = str((wchar.value)).upper()
     except UnicodeEncodeError:
         # (this fix for issue 405 caused a bug itself (see comments 6-7);
         #  this try/except fixes it)
         wchar = None
     # If the unicode char is within charmap keys (ascii value), then we use
     # the corresponding symbol.
     if wchar in charmap.keys():
         symbol = charmap[wchar]
     else:
         sym = c_uint32()
         carbon.GetEventParameter(ev, kEventParamKeyCode,
                                  typeUInt32, c_void_p(), sizeof(sym), c_void_p(), byref(sym))
         symbol = keymap.get(sym.value, None)
         if symbol is None:
             symbol = key.user_key(sym.value)
     modifiers = c_uint32()
     carbon.GetEventParameter(ev, kEventParamKeyModifiers,
         typeUInt32, c_void_p(), sizeof(modifiers), c_void_p(),
         byref(modifiers))
     return (symbol, CarbonWindow._map_modifiers(modifiers.value))
Example #2
0
 def _get_symbol_and_modifiers(ev):
     # The unicode char help processing virtual keycodes (see issue 405)
     wchar = c_wchar()
     carbon.GetEventParameter(ev, kEventParamKeyUnicodes,
         typeUnicodeText, c_void_p(), sizeof(wchar), c_void_p(), byref(wchar))
     try:
         wchar = str((wchar.value)).upper()
     except UnicodeEncodeError:
         # (this fix for issue 405 caused a bug itself (see comments 6-7);
         #  this try/except fixes it)
         wchar = None
     # If the unicode char is within charmap keys (ascii value), then we use
     # the corresponding symbol.
     if wchar in charmap.keys():
         symbol = charmap[wchar]
     else:
         sym = c_uint32()
         carbon.GetEventParameter(ev, kEventParamKeyCode,
                                  typeUInt32, c_void_p(), sizeof(sym), c_void_p(), byref(sym))
         symbol = keymap.get(sym.value, None)
         if symbol is None:
             symbol = key.user_key(sym.value)
     modifiers = c_uint32()
     carbon.GetEventParameter(ev, kEventParamKeyModifiers,
         typeUInt32, c_void_p(), sizeof(modifiers), c_void_p(),
         byref(modifiers))
     return (symbol, CarbonWindow._map_modifiers(modifiers.value))