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

Feature request: add optional scroll to the TextInput widget [$34] #1449

Closed
ghost opened this issue Aug 18, 2013 · 7 comments
Closed

Feature request: add optional scroll to the TextInput widget [$34] #1449

ghost opened this issue Aug 18, 2013 · 7 comments
Labels
bounty Includes a bounty Component: Widgets kivy/uix, style.kv

Comments

@ghost
Copy link

ghost commented Aug 18, 2013

The TextInput widget needs a scrollbar / scroll capability on x, y axis when the text overflows in it.

If one attaches TextInput to ScrollView like this, the TextInput object will be scrolled, moved around, not the actual text in the widget:

ScrollView:
    id: scrlv
    TextInput:
        text: disp_text
        size_hint: 1, None
        height: max( (len(self._lines)+1) * self.line_height, scrlv.height)

There is a $34 open bounty on this issue. Add to the bounty at Bountysource.

@tito
Copy link
Member

tito commented Aug 19, 2013

From master, the corresponding Kv would be:

ScrollView:
    TextInput:
        size_hint_y: None
        height: self.minimum_height

As many others widgets, if you want a textinput with a scrollbar, just make the assembly as showed in the kv. That's not more complex than that. It would be complex if we start to mix behavior for your own need.

The kivy way is not to make all the widgets complex and hard to maintain, but cut into small and reusable piece.

@tito tito closed this as completed Aug 19, 2013
@tshirtman
Copy link
Member

I disagree, there are good reasons for which the TextInput should control its scrolling, the visibility of the cursor is one of them, when you go up/down, you want moving the cursor to control the scrolling, and you want the view to go back to cursor when you start typing. Currently the TextInput can scroll when the text is larger than the container, but there is no scrollbar to it, and no touch management, only keyboard can control it, if you put the TextInput in a ScrollView, then you lose the keyboard-controlled scrolling, and the sync between cursor position and view.

@tito
Copy link
Member

tito commented Aug 19, 2013

Ok, +1.

@tito tito reopened this Aug 19, 2013
@ghost
Copy link
Author

ghost commented Aug 19, 2013

Thanks tito for reopening it, using your code gives me a textinput that changes it's size and the widget scrolls up and down, not the text, it's the same as the code posted by me.

@ghost ghost closed this as completed Aug 19, 2013
@ghost ghost reopened this Aug 19, 2013
@ghost ghost changed the title Feature request: add optional scroll to the TextInput widget Feature request: add optional scroll to the TextInput widget [$35] Jul 17, 2014
@ghost ghost added the bounty label Jul 17, 2014
@tshirtman tshirtman modified the milestones: 1.9.1, 1.9.0 Sep 14, 2014
@tito tito changed the title Feature request: add optional scroll to the TextInput widget [$35] Feature request: add optional scroll to the TextInput widget [$34] Feb 21, 2015
@ndapost
Copy link

ndapost commented Aug 20, 2015

py:

  class Root(BoxLayout):
       def change_scroll_y(self, ti, scrlv):
             y_cursor = ti.cursor_pos[1]
             y_bar = scrlv.scroll_y * (ti.height-scrlv.height)
             if ti.height > scrlv.height:
                    if y_cursor >= y_bar + scrlv.height:
                            dy = y_cursor - (y_bar + scrlv.height)
                            scrlv.scroll_y = scrlv.scroll_y + scrlv.convert_distance_to_scroll(0, dy)[1] 
                    if y_cursor - ti.line_height <= y_bar:
                            dy = (y_cursor - ti.line_height) - y_bar
                            scrlv.scroll_y = scrlv.scroll_y + scrlv.convert_distance_to_scroll(0, dy)[1] 

kv:

Root:    
    ScrollView:
        id: scrlv
        bar_width: 10
        scroll_type: ['bars', 'content']
        size_hint: 0.2, 0.2
        bar_inactive_color: self.bar_color        
    TextInput:
        id: ti
        font_size: 23
        size_hint: 1, None
        height: max(self.minimum_height, scrlv.height)
        on_cursor_row: root.change_scroll_y(ti, scrlv)

@dessant dessant modified the milestones: 1.9.2, 1.9.1 Oct 22, 2015
@brentpicasso
Copy link
Contributor

brentpicasso commented Feb 10, 2019

+1 right now on a mobile device, it is impossible to scroll a TextInput with just the touch interface.

@matham matham removed this from the 2.0.0 milestone Oct 28, 2020
@misl6
Copy link
Member

misl6 commented Oct 3, 2021

The issue have been fixed by @DexerBR via #7610

@misl6 misl6 closed this as completed Oct 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty Includes a bounty Component: Widgets kivy/uix, style.kv
Projects
None yet
Development

No branches or pull requests

7 participants