kivy-tips: 自分の中でのボタンのイメージ通りのUIX
Kivyを
https://github.com/kivy/kivy/blob/master/kivy/uix/behaviors.py#L108
def on_touch_up(self, touch):
if touch.grab_current is not self:
return super(ButtonBehavior, self).on_touch_up(touch)
assert(self in touch.ud)
touch.ungrab(self)
self.last_touch = touch
self._do_release()
self.dispatch('on_release')
return True
ここで、
https://github.com/attakei/kivy-chips/blob/master/strict_uix/strict/behaviors.py
こんな
from kivy.uix.behaviors import ButtonBehavior
def is_released_on(released_pos, widget):
touched_area_x = (widget.pos[0], widget.pos[0] + widget.size[0])
touched_area_y = (widget.pos[1], widget.pos[1] + widget.size[1])
if touched_area_x[0] < released_pos[0] < touched_area_x[1] and \
touched_area_y[0] < released_pos[1] < touched_area_y[1]:
return True
return False
class StrictButtonBehavior(ButtonBehavior):
def on_touch_up(self, touch):
if touch.grab_current is not self:
return super(ButtonBehavior, self).on_touch_up(touch)
assert(self in touch.ud)
touch.ungrab(self)
self.last_touch = touch
self._do_release()
if is_released_on(touch.pos, self):
self.dispatch('on_release')
return True
以下、
※補足
※脚注
tinkererを使ったブログなどに切替中
BRASS UP! Z~!!《ブラスサウンドで知る田中公平と伊藤賢治の正体》~おまけライブ付きだよ~