Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We should have a better handling of scroll_x when executing do_backspace method from TextInput #8489

Closed
FilipeMarch opened this issue Dec 1, 2023 · 2 comments

Comments

@FilipeMarch
Copy link
Contributor

FilipeMarch commented Dec 1, 2023

Is your feature request related to a problem? Please describe.
When you're pressing backspace on a long TextInput, you stop seeing the characters. So you simply do not know what you're erasing. You need to guess what you are erasing, or you need to memorize the order of characters to know exactly what you're erasing, or you need to manually move the cursor to know where you are, because the scroll_x update is not being handled properly.

Describe the solution you'd like
If the TextInput has text, any part of the text should be visible. If the text "Hello World is Awesome" is written on a TextInput and you delete the "is Awesome", you should still be able to see "Hello World". I think we just need to update the scroll_x after the backspace has already been handled.

Video showing the issue

textinput_do_backspace-2023-11-30_22.40.32.mp4
@Julian-O
Copy link
Contributor

Julian-O commented Dec 1, 2023

Closing as duplicate of #4951.

If you think this is in error, please let us know.

@Julian-O Julian-O closed this as not planned Won't fix, can't repro, duplicate, stale Dec 1, 2023
@ElliotGarbus
Copy link
Contributor

@FilipeMarch Here is a workaround.

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.textinput import TextInput
from kivy.properties import NumericProperty

kv = """
AnchorLayout:
    ScrollBackTextInput:
        size_hint: None, None
        size: dp(150), dp(30)
        multiline: False
        scroll_back: self.width - 20  # scroll back is related to the size of the text box
"""


class ScrollBackTextInput(TextInput):
    scroll_back = NumericProperty(90)

    def on_text(self, *args):
        if self.x + self.padding[0] >= self.cursor_pos[0]:
            # cursor is on left hand side, padding[0] is padding on the left
            # if the cursor hits the left hand side, scroll to the left
            self.scroll_x = max(0, self.scroll_x - self.scroll_back)


class TiTestApp(App):
    def build(self):
        return Builder.load_string(kv)


TiTestApp().run()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants