diff cagou/core/widgets_handler.py @ 155:a0e486074d91

widget handler: block carousel swiping when there is only one slide
author Goffi <goffi@goffi.org>
date Fri, 27 Apr 2018 16:46:58 +0200
parents a5e8833184c6
children 916af9c1cb9b
line wrap: on
line diff
--- a/cagou/core/widgets_handler.py	Fri Apr 27 16:45:09 2018 +0200
+++ b/cagou/core/widgets_handler.py	Fri Apr 27 16:46:58 2018 +0200
@@ -25,6 +25,7 @@
 from kivy.graphics import Color, Ellipse
 from kivy.uix.layout import Layout
 from kivy.uix.boxlayout import BoxLayout
+from kivy.uix.stencilview import StencilView
 from kivy.metrics import dp
 from kivy import properties
 from cagou import G
@@ -157,7 +158,11 @@
             touch.ud['ori_width'] = self.width
             self._draw_ellipse()
         else:
-            return super(WHWrapper, self).on_touch_down(touch)
+            if len(self.carousel.slides) == 1:
+                # we don't want swipe if there is only one slide
+                return StencilView.on_touch_down(self.carousel, touch)
+            else:
+                return super(WHWrapper, self).on_touch_down(touch)
 
     def on_touch_move(self, touch):
         """handle size change and widget creation on split"""