Scrollview with double tap on lines, always returns the last item in the list no matter what. Can you guys help me figureout the issue?

25 views
Skip to first unread message

julc...@gmail.com

unread,
Dec 25, 2018, 3:06:58 AM12/25/18
to Kivy users support


Hi,

My app is essentially

App -> Screen Manager -> Screen1 -> ScrollView
                                         Screen2
                                          .
                                          .
                                          .

Currently prototyping in Ubuntu/python2 and latest kivy version

Every line in the scrollview is a MyLines instance where I catch  double tap on a line to trigger the following action.

No matter what line I double  tap, only the last item in the scroll list is selected. I just can't figure out why.

<MyLines>:
       
    orientation: "horizontal"
    size_hint_y : None
   
    Label:
        id : contenido
       
    Label:
        id : fcompra
   
    Label:
        id : caduca

    Image:
        id : thumbnail
        center_x: self.parent.center_x
        center_y: self.parent.center_y



Everytime an update is required ths function is triggered

    def load_grid(self,sel=None):
 
        g
=self.ids.idgrid
        g
.clear_widgets()
       
       
for d in get_items(sel,self.consumido): #get_items list(dic())
            g
.add_widget(MyLines(data=d))
        g
.bind(minimum_height=g.setter('height'))



MyLines Class catchs the double tap to trigger a change of screen

    def on_touch_down(self,touch):
       
if touch.is_double_tap:
           
print(self.data)  # always print the last item in the scrollview list
           
       
return True


julc...@gmail.com

unread,
Dec 25, 2018, 3:34:23 AM12/25/18
to Kivy users support
BTW MyLines is a boxlayout

Elliot Garbus

unread,
Dec 25, 2018, 8:33:24 AM12/25/18
to Kivy users support
Test if self.collide_point(*touch.pos) is True.  Each widget receives all of the  touch events.  In the touch event handler you need to see if this widget was touched with collide_point().

julc...@gmail.com

unread,
Dec 25, 2018, 12:43:24 PM12/25/18
to Kivy users support


Thank you. Yes collide_point do3es the trick.

I was utterly confused because I have used several times in the past scrollview. But in the past, my scroll view was composed of buttons and I was testing for on_press or on_state.

Never before I had been using a scrollview composed of layouts with multiple widgets. Hence, the need for a complete different event checking.

Cheers.

JC

On Tuesday, 25 December 2018 09:06:58 UTC+1, julc...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages