Button clicks from within ScrollView not captured

154 views
Skip to first unread message

Omar Little

unread,
Nov 22, 2016, 4:40:12 AM11/22/16
to Kivy users support
(deleted old thread due to a typo, why can't users edit their posts on these forums???)

Hi,

I am having big problems making Scrollview work on a Sony LT26i running Android 4.1.2. It works on all other devices I have tested so far - although it might be more devices are having the issue.

The issue is that a user click on a button nested within a Scrollview does not trigger the button's on_press, but triggers the scrollview's on_scroll_move instead. I do not know why this problem seems specific to the device. Clicking buttons outside the scrollview works fine.

I have found topics about this issue but they´re all very old. I am attaching a minimal example of the code I am using (ignore the module list)


from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.gridlayout import GridLayout
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.scrollview import ScrollView

Builder.load_string('''
<MainScreen>:
    ScreenManager:
        id: _screen_manager
        Screen:
            name: 'Browser'
            ScrollView:
                on_scroll_move: root.scrollMove()
                GridLayout:
                    id: _browserFolders
                    cols: 1
                    size_hint_y: None
                    do_scroll_x: False
''')

class MainScreen(BoxLayout):
   
    def __init__(self, **kwargs):
        super(MainScreen, self).__init__(**kwargs)
        for i in range (0,30):
            folderButton = Button(text=str(i), size_hint_y = None, height = 150)
            folderButton.bind(on_press=self.selectFolder)
            self.ids._browserFolders.add_widget(folderButton)
            self.ids._browserFolders.bind(minimum_height=self.ids._browserFolders.setter('height'))

    def selectFolder(self,button):
        print ("trace button pressed",button.text)

    def scrollMove(self,*args):
        print ("trace scroll move")

class TestApp(App):
    def build(self):
        return MainScreen()
       
if __name__ == "__main__":
    TestApp().run()


When running the App I am getting the trace using Android Studio. the vast majority of the single clicks are calling the scrollMove function.
The issue exists regardless if I use the Kivy Launcher or if I install from an APK.

Any idea what to do with this? Thanks...

ZenCODE

unread,
Nov 22, 2016, 1:11:18 PM11/22/16
to Kivy users support
Have you tried experimenting with the scroll_distance/scroll_timeout etc? It may be that a bit of tweaking these helps?

https://kivy.org/docs/api-kivy.config.html

Omar Little

unread,
Nov 23, 2016, 3:39:49 AM11/23/16
to Kivy users support
Changing these doesn't seem to help at all.
That includes setting distance to 100000 pixels and timeout to a 1ms.

Assuming these settings are doing anything (I haven't tried on a device with no issue), the bug could well make these irrelevant.

Unless I did that wrong? Is it correct that I only need to change the config.ini file on the app folder without the need to rebuild the whole thing through Buildozer?
Because here's what I did: root the device (yikes), pull the config file from .kivy sub folder in app folder, edit the ini on host to try several combinations, putting it back to location, making sure app is stopped, restart the app, look at logs again and app behaviour.

On a different note, there are other config tokens as well in that config file which the documentation says are deprecated. Same documentation says scroll_timeout is now defaulted to 55 after version 1.5.0 .However I´m using version 1.9.1 and the deprecated tokens are still listed, and the timeout is still defaulted to 250.  

I don't intend to build business on my app, but this is core functionality and I cannot afford having users unable to click on a button :)
Is it possible to have some of the kivy gourous look into this?

Melantone14

unread,
Nov 24, 2016, 6:54:48 PM11/24/16
to Kivy users support

Version 1.9.1 on Android has a bug which prevents under some conditions (not always) to dispatch touch event to children of a ScrollView. There is a new versions in 1.9.2 which works very well. I copied the code from 1.9.2 in my code and renamed it ScrollView2 and use Scrollview2 instead of Scrollview: it works without any problem.

Michael Kramer

unread,
Nov 25, 2016, 12:02:26 AM11/25/16
to Kivy users support
This is a very interesting suggestion - thank you!

For the devices and firmware versions I was noticing the problem it was the case that it was difficult to get the touch events to be dispatched to the children reliably.  The touch events would/could get dispatched but it would often take several presses to get things to work as expected.

And again it was very device and firmware dependent - so confusing.

I will give your suggestion a try and see how it works and report back.

thanks,

Mike


On Thu, Nov 24, 2016 at 5:54 PM, Melantone14 <rot...@gmail.com> wrote:

Version 1.9.1 on Android has a bug which prevents under some conditions (not always) to dispatch touch event to children of a ScrollView. There is a new versions in 1.9.2 which works very well. I copied the code from 1.9.2 in my code and renamed it ScrollView2 and use Scrollview2 instead of Scrollview: it works without any problem.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Omar Little

unread,
Nov 25, 2016, 2:23:14 AM11/25/16
to Kivy users support
I tried it as soon as I saw the reply. Sadly sourcing the 1.9.2 version of Scrollview based on https://kivy.org/docs/_modules/kivy/uix/scrollview.html did not solve the problem.

Omar Little

unread,
Nov 25, 2016, 2:37:58 AM11/25/16
to Kivy users support
I apologize in advance for the double post, but since I cannot edit the previous one...
 
I cannot find any log of a bug fix for this issue in 1.9.2, actually in the 1.9.2 version there is no log added for version 1.9.2, which makes me at least initially believe 1.9.1 and 1.9.2 are identical for this particular widget. That's based on the in-script comments and version logs, though, I don't have the 1.9.1 version to be able to run a diff between the 2.

On a different note, since we have two threads about this, I´d like to re-iterate that I can strip the example script from Screen and Screenmanager and still experience the issue.

Melantone14

unread,
Nov 27, 2016, 9:53:36 AM11/27/16
to Kivy users support


Il giorno venerdì 25 novembre 2016 08:23:14 UTC+1, Omar Little ha scritto:
I tried it as soon as I saw the reply. Sadly sourcing the 1.9.2 version of Scrollview based on https://kivy.org/docs/_modules/kivy/uix/scrollview.html did not solve the problem.


I forgot to say that the code of 1.9.2 needs at least one change: you must replace every ScrollView found in the code with ScrollView2. I don't remember anything else. I can post the code here if it is permitted by forum rules.


Omar Little

unread,
Nov 30, 2016, 7:30:56 AM11/30/16
to Kivy users support
Please do because I´m not sure I follow.
What I tried was to import ScrollView from the 1.9.2 script (as separate .py file) instead of importing it from kivy.uix.
Not sure how using a different name would matter? I may be missing your point.

Melantone14

unread,
Dec 4, 2016, 3:24:20 PM12/4/16
to Kivy users support
See ScrollView2 in file.

I put this file in my program dir and after:

from ScrollView2 import ScrollView2

I use ScrollView2 instead of ScrollView. Tested under Android 5. I think that the name ScrollView can be used instead of ScrollView2 but i did not tested it.
ScrollView2.py
Reply all
Reply to author
Forward
0 new messages