Table Of Contents
Events(翻訳済み)¶
Kivyは イベントベース で、プログラムの流れを意味するイベントによって決定されます
Clock events(クロックイベント)

Clock object(翻訳ずみ) は、schedule_once()
に将来的に一回限りのイベントを schedule_interval()
に繰り返し行うイベントをスケジュールできます。
You can also create Triggered events with
create_trigger()
. Triggers have the advantage of
being called only once per frame, even if you have scheduled multiple triggers
for the same callback.
Input events(入力イベント)

すべてのマウスクリック、タッチとスクロールは MotionEvent
の一部で、Input Postprocessing によって拡張され、Window クラスの中で on_motion
イベントを通じて送られます。これらのイベントは Widget
にて on_touch_down()
、 on_touch_move()
と on_touch_up()
イベントを生み出します。
詳細な説明については、Input management を見ます。
Class events(クラスイベント)

Widget
により用いられるベースクラスの EventDispatcher
は変更を送るために、Properties を使います。これは、Widgetの位置やサイズを変更したときに、対応するイベントが自動的に発生します。
加えて、Button
widget内の on_press と on_release のイベントが示すように、 register_event_type()
を使用して、独自のイベントを作成する機能を持っています。
注意すべきもう一つのこととして、イベントを上書きした場合は、ベースクラスで以前処理されたビへイビアを実装しなければなりません。これを行う簡単な方法として super() を呼び出すことです:
def on_touch_down(self, touch):
if super(OurClassName, self).on_touch_down(touch):
return True
if not self.collide_point(touch.x, touch.y):
return False
print('you touched me!')
return True
Events and Properties (翻訳済み) のドキュメントを読むことで、イベントに慣れましょう。