本文整理汇总了Python中pyglet.window.key.MOD_CTRL属性的典型用法代码示例。如果您正苦于以下问题:Python key.MOD_CTRL属性的具体用法?Python key.MOD_CTRL怎么用?Python key.MOD_CTRL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pyglet.window.key
的用法示例。
在下文中一共展示了key.MOD_CTRL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_modifiers
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import MOD_CTRL [as 别名]
def _get_modifiers(self, key_lParam=0):
modifiers = 0
if _user32.GetKeyState(VK_SHIFT) & 0xff00:
modifiers |= key.MOD_SHIFT
if _user32.GetKeyState(VK_CONTROL) & 0xff00:
modifiers |= key.MOD_CTRL
if _user32.GetKeyState(VK_LWIN) & 0xff00:
modifiers |= key.MOD_WINDOWS
if _user32.GetKeyState(VK_CAPITAL) & 0x00ff: # toggle
modifiers |= key.MOD_CAPSLOCK
if _user32.GetKeyState(VK_NUMLOCK) & 0x00ff: # toggle
modifiers |= key.MOD_NUMLOCK
if _user32.GetKeyState(VK_SCROLL) & 0x00ff: # toggle
modifiers |= key.MOD_SCROLLLOCK
if key_lParam:
if key_lParam & (1 << 29):
modifiers |= key.MOD_ALT
elif _user32.GetKeyState(VK_MENU) < 0:
modifiers |= key.MOD_ALT
return modifiers
示例2: _translate_modifiers
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import MOD_CTRL [as 别名]
def _translate_modifiers(state):
modifiers = 0
if state & xlib.ShiftMask:
modifiers |= key.MOD_SHIFT
if state & xlib.ControlMask:
modifiers |= key.MOD_CTRL
if state & xlib.LockMask:
modifiers |= key.MOD_CAPSLOCK
if state & xlib.Mod1Mask:
modifiers |= key.MOD_ALT
if state & xlib.Mod2Mask:
modifiers |= key.MOD_NUMLOCK
if state & xlib.Mod4Mask:
modifiers |= key.MOD_WINDOWS
if state & xlib.Mod5Mask:
modifiers |= key.MOD_SCROLLLOCK
return modifiers
# Event handlers
示例3: on_key_press
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import MOD_CTRL [as 别名]
def on_key_press(self, symbol, modifiers):
fullscreen = not modifiers & key.MOD_CTRL
doing = fullscreen and 'Setting' or 'Restoring from'
if symbol == key._0:
print('%s default size' % doing)
self.w.set_fullscreen(fullscreen)
return
elif symbol == key._1:
width, height = 320, 200
elif symbol == key._2:
width, height = 640, 480
elif symbol == key._3:
width, height = 800, 600
elif symbol == key._4:
width, height = 1024, 768
elif symbol == key._5:
width, height = 1280, 800 # 16:10
elif symbol == key._6:
width, height = 1280, 1024
else:
return
print('%s width=%d, height=%d' % (doing, width, height))
self.w.set_fullscreen(fullscreen, width=width, height=height)
示例4: _update_question
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import MOD_CTRL [as 别名]
def _update_question(self):
modifiers = []
if self.chosen_modifiers & key.MOD_SHIFT:
modifiers.append('<Shift>')
if self.chosen_modifiers & key.MOD_ALT:
modifiers.append('<Alt/Option>')
if self.chosen_modifiers & key.MOD_CTRL:
modifiers.append('<Ctrl>')
self.question = """Please press and release the following combination of keys.
Only use <Shift> if explicitly asked to do so.
{} {}
Press Esc if test does not pass.""".format(' '.join(modifiers), key.symbol_string(self.chosen_symbol))
self._render_question()
示例5: getModifiers
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import MOD_CTRL [as 别名]
def getModifiers(nsevent):
modifiers = 0
modifierFlags = nsevent.modifierFlags()
if modifierFlags & cocoapy.NSAlphaShiftKeyMask:
modifiers |= key.MOD_CAPSLOCK
if modifierFlags & cocoapy.NSShiftKeyMask:
modifiers |= key.MOD_SHIFT
if modifierFlags & cocoapy.NSControlKeyMask:
modifiers |= key.MOD_CTRL
if modifierFlags & cocoapy.NSAlternateKeyMask:
modifiers |= key.MOD_ALT
modifiers |= key.MOD_OPTION
if modifierFlags & cocoapy.NSCommandKeyMask:
modifiers |= key.MOD_COMMAND
if modifierFlags & cocoapy.NSFunctionKeyMask:
modifiers |= key.MOD_FUNCTION
return modifiers
示例6: modifiers_string
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import MOD_CTRL [as 别名]
def modifiers_string(modifiers):
'''Return a string describing a set of modifiers.
Example::
>>> modifiers_string(MOD_SHIFT | MOD_CTRL)
'MOD_SHIFT|MOD_CTRL'
:Parameters:
`modifiers` : int
Bitwise combination of modifier constants.
:rtype: str
'''
mod_names = []
if modifiers & MOD_SHIFT:
mod_names.append('MOD_SHIFT')
if modifiers & MOD_CTRL:
mod_names.append('MOD_CTRL')
if modifiers & MOD_ALT:
mod_names.append('MOD_ALT')
if modifiers & MOD_CAPSLOCK:
mod_names.append('MOD_CAPSLOCK')
if modifiers & MOD_NUMLOCK:
mod_names.append('MOD_NUMLOCK')
if modifiers & MOD_SCROLLLOCK:
mod_names.append('MOD_SCROLLLOCK')
if modifiers & MOD_COMMAND:
mod_names.append('MOD_COMMAND')
if modifiers & MOD_OPTION:
mod_names.append('MOD_OPTION')
if modifiers & MOD_FUNCTION:
mod_names.append('MOD_FUNCTION')
return '|'.join(mod_names)
示例7: _on_text_input
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import MOD_CTRL [as 别名]
def _on_text_input(self, next_handler, ev, data):
size = c_uint32()
carbon.GetEventParameter(ev, kEventParamTextInputSendText,
typeUTF8Text, c_void_p(), 0, byref(size), c_void_p())
text = create_string_buffer(size.value)
carbon.GetEventParameter(ev, kEventParamTextInputSendText,
typeUTF8Text, c_void_p(), size.value, c_void_p(), byref(text))
text = text.value.decode('utf8')
raw_event = EventRef()
carbon.GetEventParameter(ev, kEventParamTextInputSendKeyboardEvent,
typeEventRef, c_void_p(), sizeof(raw_event), c_void_p(),
byref(raw_event))
symbol, modifiers = self._get_symbol_and_modifiers(raw_event)
motion_modifiers = modifiers & \
(key.MOD_COMMAND | key.MOD_CTRL | key.MOD_OPTION)
if (symbol, motion_modifiers) in _motion_map:
motion = _motion_map[symbol, motion_modifiers]
if modifiers & key.MOD_SHIFT:
self.dispatch_event('on_text_motion_select', motion)
else:
self.dispatch_event('on_text_motion', motion)
elif ((unicodedata.category(text[0]) != 'Cc' or text == u'\r') and
not (modifiers & key.MOD_COMMAND)):
self.dispatch_event('on_text', text)
return noErr
示例8: _map_modifiers
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import MOD_CTRL [as 别名]
def _map_modifiers(modifiers):
mapped_modifiers = 0
if modifiers & (shiftKey | rightShiftKey):
mapped_modifiers |= key.MOD_SHIFT
if modifiers & (controlKey | rightControlKey):
mapped_modifiers |= key.MOD_CTRL
if modifiers & (optionKey | rightOptionKey):
mapped_modifiers |= key.MOD_OPTION
if modifiers & alphaLock:
mapped_modifiers |= key.MOD_CAPSLOCK
if modifiers & cmdKey:
mapped_modifiers |= key.MOD_COMMAND
return mapped_modifiers
示例9: modifiers_string
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import MOD_CTRL [as 别名]
def modifiers_string(modifiers):
'''Return a string describing a set of modifiers.
Example::
>>> modifiers_string(MOD_SHIFT | MOD_CTRL)
'MOD_SHIFT|MOD_CTRL'
:Parameters:
`modifiers` : int
Bitwise combination of modifier constants.
:rtype: str
'''
mod_names = []
if modifiers & MOD_SHIFT:
mod_names.append('MOD_SHIFT')
if modifiers & MOD_CTRL:
mod_names.append('MOD_CTRL')
if modifiers & MOD_ALT:
mod_names.append('MOD_ALT')
if modifiers & MOD_CAPSLOCK:
mod_names.append('MOD_CAPSLOCK')
if modifiers & MOD_NUMLOCK:
mod_names.append('MOD_NUMLOCK')
if modifiers & MOD_SCROLLLOCK:
mod_names.append('MOD_SCROLLLOCK')
if modifiers & MOD_COMMAND:
mod_names.append('MOD_COMMAND')
if modifiers & MOD_OPTION:
mod_names.append('MOD_OPTION')
return '|'.join(mod_names)
示例10: _event_text_motion
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import MOD_CTRL [as 别名]
def _event_text_motion(self, symbol, modifiers):
if modifiers & key.MOD_ALT:
return None
ctrl = modifiers & key.MOD_CTRL != 0
return _motion_map.get((symbol, ctrl), None)
示例11: on_mouse_press
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import MOD_CTRL [as 别名]
def on_mouse_press(self, x, y, button, modifiers):
if (button == mouse.RIGHT) or \
((button == mouse.LEFT) and (modifiers & key.MOD_CTRL)):
block, previous = self.player.hit(self.world.area.blocks, left=False)
# ON OSX, control + left click = right click.
if block and self.player.current_item:
self.world.add_block(previous, get_block(self.player.get_block()))
elif button == mouse.LEFT:
block = self.player.hit(self.world.area.blocks)[0]
if block:
texture = self.world.area.get_block(block)
if texture.hit_and_destroy():
self.world.remove_block(block)
示例12: _select_next_key
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import MOD_CTRL [as 别名]
def _select_next_key(self):
self.chosen_symbol = random.choice(self.keys)
# Little trick, Ctrl, Alt and Shift are lowest modifier values, so everything between 0 and
# the full combination is a permutation of these three.
max_modifiers = key.MOD_SHIFT | key.MOD_ALT | key.MOD_CTRL
# Give a little more weight to key without modifiers
self.chosen_modifiers = max(0, random.randint(-2, max_modifiers))
self._update_question()
示例13: _get_modifier_for_key
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import MOD_CTRL [as 别名]
def _get_modifier_for_key(self, symbol):
if symbol in self.mod_shift_keys:
return key.MOD_SHIFT
elif symbol in self.mod_alt_keys:
return key.MOD_ALT
elif symbol in self.mod_ctrl_keys:
return key.MOD_CTRL
elif symbol in self.mod_option_keys:
return key.MOD_OPTION
elif symbol in self.mod_meta_keys:
return self.mod_meta
else:
return 0
示例14: _event_text_motion
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import MOD_CTRL [as 别名]
def _event_text_motion(symbol, modifiers):
if modifiers & key.MOD_ALT:
return None
ctrl = modifiers & key.MOD_CTRL != 0
return _motion_map.get((symbol, ctrl), None)
示例15: modifiers_string
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import MOD_CTRL [as 别名]
def modifiers_string(modifiers):
"""Return a string describing a set of modifiers.
Example::
>>> modifiers_string(MOD_SHIFT | MOD_CTRL)
'MOD_SHIFT|MOD_CTRL'
:Parameters:
`modifiers` : int
Bitwise combination of modifier constants.
:rtype: str
"""
mod_names = []
if modifiers & MOD_SHIFT:
mod_names.append('MOD_SHIFT')
if modifiers & MOD_CTRL:
mod_names.append('MOD_CTRL')
if modifiers & MOD_ALT:
mod_names.append('MOD_ALT')
if modifiers & MOD_CAPSLOCK:
mod_names.append('MOD_CAPSLOCK')
if modifiers & MOD_NUMLOCK:
mod_names.append('MOD_NUMLOCK')
if modifiers & MOD_SCROLLLOCK:
mod_names.append('MOD_SCROLLLOCK')
if modifiers & MOD_COMMAND:
mod_names.append('MOD_COMMAND')
if modifiers & MOD_OPTION:
mod_names.append('MOD_OPTION')
if modifiers & MOD_FUNCTION:
mod_names.append('MOD_FUNCTION')
return '|'.join(mod_names)