def set_exclusive_mouse(self, exclusive=True):
if self._exclusive_mouse == exclusive and \
self._exclusive_mouse_focus == self._has_focus:
return
if exclusive and self._has_focus:
# Move mouse to the center of the window.
self._reset_exclusive_mouse_screen()
x, y = self._exclusive_mouse_screen
self.set_mouse_position(x, y, absolute=True)
# Clip to client area, to prevent large mouse movements taking
# it outside the client area.
rect = RECT()
_user32.GetClientRect(self._view_hwnd, byref(rect))
_user32.MapWindowPoints(self._view_hwnd, HWND_DESKTOP,
byref(rect), 2)
_user32.ClipCursor(byref(rect))
else:
# Release clip
_user32.ClipCursor(None)
self._exclusive_mouse = exclusive
self._exclusive_mouse_focus = self._has_focus
self.set_mouse_platform_visible()
评论列表
文章目录