本文整理匯總了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