Each time I tap my mouse anywhere outside kivy window and get back I have to tap the window twice to recive on_touch_down
event. Is it possible to recive that event
when I tap for the first time? The only event
I recive is Window focus
. My idea is to catch, if possible, touch
from window
argument and call on_touch_down
. OFC I'm open to any solution to that problem.
from kivy.config import Config
Config.set('graphics', 'multisamples', '0')
Config.set('graphics', 'width', '400')
Config.set('graphics', 'height', '400')
Config.write()
from kivy.app import App
from kivy.lang.builder import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.core.window import Window
kv = '''
MyWindow:
'''
class MyWindow(BoxLayout):
def __init__(self, *args, **kwargs):
super().__init__(**kwargs)
Window.bind(focus=self.window_focus)
def window_focus(self, window, focus):
print('WINDOW FOCUS', focus)
if focus:
# is it possible to get touch from window and call on_touch_down?
pass
def on_touch_down(self, touch):
print('TOUCH DOWN')
return super().on_touch_down(touch)
class MyApp(App):
def build(self):
return Builder.load_string(kv)
if __name__ == '__main__':
MyApp().run()
question from:
https://stackoverflow.com/questions/65844950/kivy-window-doesnt-recive-first-touch-when-unfocused 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…