Skip to content

Commit

Permalink
fixing bugs in text box and text entry line.
Browse files Browse the repository at this point in the history
new bugfix release
  • Loading branch information
MyreMylar committed Dec 19, 2019
1 parent b4e94a7 commit 96838bd
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
author = 'Dan Lawrence'

# The short X.Y version
version = '0.4.1'
version = '0.4.2'
# The full version, including alpha/beta/rc tags
release = '0.4.1'
release = '0.4.2'


# -- General configuration ---------------------------------------------------
Expand Down
4 changes: 1 addition & 3 deletions pygame_gui/elements/ui_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,7 @@ def update_containing_rect_position(self):
Updates the position of this element based on the position of it's container. Usually called when the container
has moved.
"""
self.rect = pygame.Rect((self.ui_container.rect.x + self.relative_rect.x,
self.ui_container.rect.y + self.relative_rect.y),
self.relative_rect.size)
super().update_containing_rect_position()

self.drawable_shape.set_position(self.rect.topleft)

Expand Down
8 changes: 8 additions & 0 deletions pygame_gui/elements/ui_text_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ def __init__(self, html_text: str,

self.rebuild_from_changed_theme_data()

def kill(self):
"""
Overrides the standard sprite kill method to also kill any scroll bar belonging to this text box.
"""
if self.scroll_bar is not None:
self.scroll_bar.kill()
super().kill()

def rebuild(self):
"""
Rebuild whatever needs building.
Expand Down
19 changes: 18 additions & 1 deletion pygame_gui/elements/ui_text_entry_line.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pygame
import re
import warnings
from typing import Union, List
from typing import Union, List, Tuple

import pygame_gui
from pygame_gui.ui_manager import UIManager
Expand Down Expand Up @@ -152,6 +152,23 @@ def rebuild(self):
# setup for drawing
self.redraw()

def set_position(self, position: Union[pygame.math.Vector2, Tuple[int, int], Tuple[float, float]]):
"""
Method to directly set the absolute rect position of a text entry line.
:param position: The new position to set.
"""
super().set_position(position)
self.drawable_shape.set_position(self.rect.topleft)

def update_containing_rect_position(self):
"""
Updates the position of this element based on the position of it's container. Usually called when the container
has moved.
"""
super().update_containing_rect_position()
self.drawable_shape.set_position(self.rect.topleft)

def set_text_length_limit(self, limit: int):
"""
Allows a character limit to be set on the text entry element. By default there is no limit on the number
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def _post_install():
setup(
cmdclass={'develop': DevelopOnlyInstall},
name='pygame_gui',
version='0.4.1',
version='0.4.2',
description='A GUI module for pygame 2',
long_description="Helps create GUIs for games made using pygame 2. Features HTML-style text formatting, "
"theme files to control the look and a system to manage multiple windows of GUI stuff.",
Expand Down

0 comments on commit 96838bd

Please sign in to comment.