Skip to content

Commit 9c90129

Browse files
authored
Gui/fix caret misplaced (#2750)
* gui: fix caret offset after UIInputText is resized * gui: cleanup test execution
1 parent 6113762 commit 9c90129

File tree

3 files changed

+28
-18
lines changed

3 files changed

+28
-18
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
You can grab pre-release versions from PyPi. See the available versions from the
44
Arcade [PyPi Release History](https://pypi.org/project/arcade/#history) page.
55

6+
## Unreleased
7+
8+
- GUI
9+
- Fix a bug, where the caret of UIInputText was misplaced after resizing the widget
10+
611
## 3.3.2
712

813
- GUI

arcade/gui/widgets/text.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,9 @@ def _update_layout(self):
735735
layout.y = 0
736736
layout.end_update()
737737

738+
# manually update caret position
739+
self.caret.on_layout_update()
740+
738741
@property
739742
def text(self):
740743
"""Text of the input field."""

tests/unit/gui/test_widget_tree.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,25 @@ def objs_in_memory(obj_type):
131131
del root
132132
gc.collect()
133133

134-
if objs_in_memory(UIWidget) > start_count:
135-
print("Render object graph...")
136-
import objgraph
137-
138-
objgraph.show_chain(
139-
objgraph.find_backref_chain(
140-
[obj for obj in gc.get_objects() if isinstance(obj, UIWidget)][1],
141-
objgraph.is_proper_module,
142-
),
143-
# filename="chain.png",
144-
)
145-
146-
# print("Render backrefs...")
147-
# objgraph.show_backrefs(
148-
# [[obj for obj in gc.get_objects() if isinstance(obj, UIWidget)][1]],
149-
# max_depth=15,
150-
# # filename="sample-graph.png",
151-
# )
134+
# This might help, if the test fails ;)
135+
# requires `objgraph`
136+
# if objs_in_memory(UIWidget) > start_count:
137+
# print("Render object graph...")
138+
# import objgraph
139+
#
140+
# objgraph.show_chain(
141+
# objgraph.find_backref_chain(
142+
# [obj for obj in gc.get_objects() if isinstance(obj, UIWidget)][1],
143+
# objgraph.is_proper_module,
144+
# ),
145+
# # filename="chain.png",
146+
# )
147+
148+
# print("Render backrefs...")
149+
# objgraph.show_backrefs(
150+
# [[obj for obj in gc.get_objects() if isinstance(obj, UIWidget)][1]],
151+
# max_depth=15,
152+
# # filename="sample-graph.png",
153+
# )
152154

153155
assert objs_in_memory(UIWidget) == start_count

0 commit comments

Comments
 (0)