From 92ff508dc17831a57a4bb900d7bc218b577e066e Mon Sep 17 00:00:00 2001 From: Dexer <73297572+DexerBR@users.noreply.github.com> Date: Sun, 5 Sep 2021 10:47:16 -0300 Subject: [PATCH] Fixed unexpected overscrolling when using mouse wheel (#7612) --- kivy/uix/textinput.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/kivy/uix/textinput.py b/kivy/uix/textinput.py index 25d534bc2..810909f93 100644 --- a/kivy/uix/textinput.py +++ b/kivy/uix/textinput.py @@ -1504,7 +1504,8 @@ class TextInput(FocusBehavior, Widget): self._trigger_update_graphics() else: if self.scroll_x > 0: - self.scroll_x -= self.line_height + self.scroll_x = max(0, self.scroll_x - + self.line_height) self._trigger_update_graphics() if scroll_type == 'up': if self.multiline: @@ -1516,9 +1517,12 @@ class TextInput(FocusBehavior, Widget): self.scroll_y += self.line_height self._trigger_update_graphics() else: - if (self.scroll_x + self.width < - self._lines_rects[-1].texture.size[0]): - self.scroll_x += self.line_height + minimum_width = (self._lines_rects[-1].texture.size[0] + + self.padding[0] + self.padding[2]) + max_scroll_x = max(0, minimum_width - self.width) + if self.scroll_x < max_scroll_x: + self.scroll_x = min(max_scroll_x, self.scroll_x + + self.line_height) self._trigger_update_graphics() return True