community icon indicating copy to clipboard operation
community copied to clipboard

Fix TextInput cursor using padding_bottom instead of top

Open Cheaterman opened this issue 2 months ago • 0 comments

Reproduction:

from kivy.app import App
from kivy.lang.builder import Builder

KV = '''
TextInput:
    padding: [10, 10, 10, 30]
'''


class TestApp(App):
    def build(self):
        return Builder.load_string(KV)


TestApp().run()

As you can see, the cursor and text position don't match. The root cause is that for cursor visual pos, textinput is calculating max_y as self.top - self.padding_bottom instead of self.top - self.padding_top (not real attributes, just pseudocode to make the point more clear).

Maintainer merge checklist

  • [ ] Title is descriptive/clear for inclusion in release notes.
  • [ ] Applied a Component: xxx label.
  • [ ] Applied the api-deprecation or api-break label.
  • [ ] Applied the release-highlight label to be highlighted in release notes.
  • [ ] Added to the milestone version it was merged into.
  • [ ] Unittests are included in PR.
  • [ ] Properly documented, including versionadded, versionchanged as needed.

Cheaterman avatar Jun 27 '24 11:06 Cheaterman