<p>我想出了一个简单的覆盖<code>ScrollView</code>的{<cd2>},目前看来它满足了我的需求。这样做的目的是测试触摸事件是否属于“排除区域”(在下面的示例中,只检查x维,但将其扩展到任意矩形区域并不重要)。如果它确实属于该排除区域,<code>on_touch_down</code>事件将被调度到<code>ScrollView</code>的子级。如果孩子被吞咽了,那就抓到了。在所有其他情况下,<code>super.on_touch_down</code>将被调用,即启动正常的滚动行为。这样做的好处是,如果触摸不到<code>Slider</code>(在问题的例子中),仍然可以滚动。在</p>
<pre><code>class MSV(ScrollView):
x_exclusion_lower = NumericProperty(None, allownone=True)
x_exclusion_upper = NumericProperty(None, allownone=True)
x_exclusion = ReferenceListProperty(x_exclusion_lower, x_exclusion_upper)
def on_touch_down(self, touch):
pos_in_sv = self.to_local(*touch.pos)
if (self.x_exclusion_lower is not None or self.x_exclusion_upper is not None) and (self.x_exclusion_lower is None or self.x_exclusion_lower <= pos_in_sv[0]) and \
(self.x_exclusion_upper is None or self.x_exclusion_upper >= pos_in_sv[0]):
touch.push()
touch.apply_transform_2d(self.to_local)
if self.dispatch_children('on_touch_down', touch):
return True
touch.pop()
super(MSV, self).on_touch_down(touch)
</code></pre>