Here is an example that can easily be extended to do what you are looking for. The example is a little sophisticated registering a new event and dispatching that event. This is how I would implement it to simplify use in kv, but it is not required.
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.button import Button
from kivy.clock import Clock
kv = """
BoxLayout:
orientation: 'vertical'
Button:
text: 'Regular Button'
FiveSecondButton:
text: 'Five Second Button'
on_press: self.text = 'Pressed'
on_release: self.text = 'Five Second Button'
on_five_second_press: self.text = 'Very Long Press'
"""
class FiveSecondButton(Button):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.schedule = None
self.register_event_type('on_five_second_press')
def on_five_second_press(self):
pass
def on_press(self):
self.schedule = Clock.schedule_once(self._long_press, 5)
def _long_press(self, _):
self.dispatch('on_five_second_press')
def on_release(self):
self.schedule.cancel()
class FiveSecondApp(App):
def build(self):
return Builder.load_string(kv)
FiveSecondApp().run()
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/aff473d2-5b8a-4a6b-a93e-8c5fca0a738fn%40googlegroups.com.