Skip to content

Remove Window.grab, add Window.grab_mode and Window.grabbed #2164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion buildconfig/stubs/pygame/_sdl2/video.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class Window:
) -> None: ...
@classmethod
def from_display_module(cls) -> Window: ...
grab: bool
grab_mode: bool
grabbed: bool
relative_mouse: bool
def set_windowed(self) -> None: ...
def set_fullscreen(self, desktop: bool = False) -> None: ...
Expand Down
3 changes: 2 additions & 1 deletion buildconfig/stubs/pygame/_window.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class Window:
def minimize(self) -> None: ...
def set_modal_for(self, parent: Window) -> None: ...
def set_icon(self, icon: Surface) -> None: ...
grab: bool
grab_mode: bool
grabbed: bool
title: str
resizable: bool
borderless: bool
Expand Down
20 changes: 13 additions & 7 deletions docs/reST/ref/sdl2_video.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,22 @@
:param bool popup_menu: Create a window that should be treated as a popup menu
(X11 only, >= SDL 2.0.5).

.. attribute:: grabbed

.. attribute:: grab
| :sl:`Get whether the mouse is confined to the window. (**read-only**)`
| :sg:`grabbed -> bool`

.. attribute:: grab_mode

| :sl:`Get or set the window's input grab state`
| :sg:`grab -> bool`
| :sl:`Get or set whether the window is in grab mode.`
| :sg:`grab_mode -> bool`

Gets or sets the window's input grab state.
When input is grabbed, the mouse is confined to the window.
If the caller enables a grab while another window is currently grabbed,
the other window loses its grab in favor of the caller's window.
Get or set whether the window is in grab mode.
When set to ``True``, the window will be able to grab the mouse but
will not confine the mouse immediately. Once the window gains focus,
the mouse will be confined and :attr:`Window.grabbed` turns to ``True``.
Once this attribute is set to ``False`` or the window loses focus,
the mouse will be released and :attr:`Window.grabbed` turns to ``False``

.. attribute:: relative_mouse

Expand Down
Loading