本文整理汇总了Python中curses.ungetmouse方法的典型用法代码示例。如果您正苦于以下问题:Python curses.ungetmouse方法的具体用法?Python curses.ungetmouse怎么用?Python curses.ungetmouse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类curses
的用法示例。
在下文中一共展示了curses.ungetmouse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _inject_mouse
# 需要导入模块: import curses [as 别名]
# 或者: from curses import ungetmouse [as 别名]
def _inject_mouse(screen, x, y, button):
"""
Inject a mouse event into the input buffers.
"""
if sys.platform == "win32":
event = win32console.PyINPUT_RECORDType(win32console.MOUSE_EVENT)
event.MousePosition.X = x
event.MousePosition.Y = y
if button & MouseEvent.LEFT_CLICK != 0:
event.ButtonState |= win32con.FROM_LEFT_1ST_BUTTON_PRESSED
if button & MouseEvent.RIGHT_CLICK != 0:
event.ButtonState |= win32con.RIGHTMOST_BUTTON_PRESSED
if button & MouseEvent.DOUBLE_CLICK != 0:
event.EventFlags |= win32con.DOUBLE_CLICK
screen._stdin.WriteConsoleInput([event])
else:
# Curses doesn't like no value in some cases - use a dummy button
# click which we don't use instead.
bstate = curses.BUTTON4_CLICKED
if button & MouseEvent.LEFT_CLICK != 0:
bstate |= curses.BUTTON1_CLICKED
if button & MouseEvent.RIGHT_CLICK != 0:
bstate |= curses.BUTTON3_CLICKED
if button & MouseEvent.DOUBLE_CLICK != 0:
bstate |= curses.BUTTON1_DOUBLE_CLICKED
curses.ungetmouse(0, x, y, 0, bstate)
示例2: h_exit_mouse
# 需要导入模块: import curses [as 别名]
# 或者: from curses import ungetmouse [as 别名]
def h_exit_mouse(self, _input):
mouse_event = self.parent.safe_get_mouse_event()
if mouse_event and self.intersted_in_mouse_event(mouse_event):
self.handle_mouse_event(mouse_event)
else:
if mouse_event and self._test_safe_to_exit():
curses.ungetmouse(*mouse_event)
ch = self.parent.curses_pad.getch()
assert ch == curses.KEY_MOUSE
self.editing = False
self.how_exited = EXITED_MOUSE