Skip to content

Commit

Permalink
Merge pull request #294 from TechStudent10/main
Browse files Browse the repository at this point in the history
Add parameter to `UIWindow` to make it undraggable
  • Loading branch information
MyreMylar authored Dec 31, 2022
2 parents e62400e + 0fef2fd commit 0abe9c1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pygame_gui/elements/ui_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ def __init__(self,
element_id: Optional[str] = None,
object_id: Optional[Union[ObjectID, str]] = None,
resizable: bool = False,
visible: int = 1):
visible: int = 1,
draggable: bool = True):

self.window_display_title = window_display_title
self._window_root_container = None # type: Optional[UIContainer]
self.resizable = resizable
self.draggable = draggable
self.minimum_dimensions = (100, 100)
self.edge_hovering = [False, False, False, False]

Expand Down Expand Up @@ -286,7 +288,8 @@ def update(self, time_delta: float):
current_grab_difference[1] -
self.starting_grab_difference[1])

self.set_relative_position((self.relative_rect.x + adjustment_required[0],
if self.draggable:
self.set_relative_position((self.relative_rect.x + adjustment_required[0],
self.relative_rect.y + adjustment_required[1]))
else:
self.grabbed_window = False
Expand Down

0 comments on commit 0abe9c1

Please sign in to comment.