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

TextInput does not paginate when multiline is False #4951

Closed
dessant opened this issue Jan 26, 2017 · 9 comments
Closed

TextInput does not paginate when multiline is False #4951

dessant opened this issue Jan 26, 2017 · 9 comments
Labels
Component: Widgets kivy/uix, style.kv Status: Confirmed Confirmed as real issue Type: Feature Issue is a feature request

Comments

@dessant
Copy link
Contributor

dessant commented Jan 26, 2017

Versions

  • Python: 3.4.4
  • OS: Windows 10
  • Kivy: master - 284b613

Description

TextInput does not paginate during character insertions and deletions when multiline is False.
Here are two ways to reproduce the bug:

  • type text in the first input until it is overfilled, then start deleting the text with backspace, repeat the same actions for the second input

    kivy

  • paste text in the first input with CTRL+V until it is overfilled, then type CTRL+Z, repeat the same actions for the second input

    kivy2

Code and Logs

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


kv = """
BoxLayout:
    orientation: 'vertical'
    size_hint: None, None
    size: self.minimum_size
    pos_hint: {'center_x': 0.5, 'center_y': 0.5}
    spacing: dp(16)

    TextInput:
        text: 'multiline=True'
        size_hint: None, None
        size: dp(200), dp(40)
        font_size: dp(24)

    TextInput:
        text: 'multiline=False'
        multiline: False
        size_hint: None, None
        size: dp(200), dp(40)
        font_size: dp(24)
"""


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


if __name__ == '__main__':
    TestApp().run()
@dessant dessant added the Component: Widgets kivy/uix, style.kv label Jan 26, 2017
@dessant
Copy link
Contributor Author

dessant commented Jan 27, 2017

Pagination is not present regardless of the value of multiline in 1.9.1 and earlier versions.

@dessant
Copy link
Contributor Author

dessant commented Jan 27, 2017

The right fix will likely involve examining how different browser inputs behave in these cases and emulating that. The behavior differs in all Kivy versions from that of html inputs, regardless of multiline.

@Zen-CODE
Copy link
Member

For my 2c, this works as expected. 'multiline' is does not equate to pagination. With multiline True, it wraps automatically to multiple lines, otherwise text continues on a single line. I think this behavior makes sense and consistent with the docs?

And it's not clear what 'pagination' would mean in the context of TextInput. Perhaps you could elaborate?

@dessant
Copy link
Contributor Author

dessant commented Feb 28, 2017

I called pagination what is seen on the gif when multiline is True. I'm not that much for pagination either, but the current behavior does not seem correct when multiline is False, compare it to a html input in your browser.

One issue is the text that is about to be deleted not being visible after the cursor has reached the left side of the input.

@stale
Copy link

stale bot commented Oct 7, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 7, 2017
@KeyWeeUsr KeyWeeUsr added the Status: Confirmed Confirmed as real issue label Oct 15, 2017
@stale stale bot removed the stale label Oct 15, 2017
@hamida005
Copy link

Mot de passe

@Julian-O
Copy link
Contributor

Julian-O commented Nov 8, 2023

Reproduced the problem on Kivy 2.2.1, Windows 11.

Restating the problem, because I found the descriptions tough to understand:

The two boxes are both only tall enough to display one line of text.

The former has multiline turned on by default, which allows you to include new-lines into the text. If you hit enter, it will show the current line of a multi-text window.

The latter has multiline turned off. It ignores enter.

Multi-line windows have a second feature: Word-wrapping. It is on by default (can be turned off with do_wrap: False). If you type a word surrounded by spaces that does fit on the screen, it wraps it around to the next line (without inserting a new line character)

The word-wrapping doesn't seem to wrap the lines in this example, because of the widget size. If the widget is made larger, it shows more of the lines, and the wrapping is visible.

Another behaviour that is controlled by word-wrapping: As you move near/past the edges of the textbox, the displayed jumps to show the previous "page" of text.

Multiline off:

  • No newlines.
  • No word-wrapping
    • Hence no auto-movement of the display to better see the text.

Multiline on with explicit do_wrap: False

  • Newlines accepted.
  • No word-wrapping
    • Hence no auto-movement of the display to better see the text.

Multiline on with default do_wrap: True

  • Newlines accepted.
  • Word-wrapping
    • Auto-movement of the display to better see the text.

The OP is effectively asking for the same auto-movement of the text when word-wrapping is turned off.

@ElliotGarbus
Copy link
Contributor

Here is a workaround in user code. Let me know if you think this is sufficient or if it would be better change to the TextInput widget.

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()

@Julian-O
Copy link
Contributor

Julian-O commented Dec 2, 2023

I vote fix the widget. I believe there is bigger-picture edits happening to TextInput right now, and there seem to be a few PRs in the queue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Widgets kivy/uix, style.kv Status: Confirmed Confirmed as real issue Type: Feature Issue is a feature request
Projects
None yet
Development

No branches or pull requests

6 participants