Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextInput error because of Window #24

Open
thomassedlmayer opened this issue May 3, 2023 · 0 comments
Open

TextInput error because of Window #24

thomassedlmayer opened this issue May 3, 2023 · 0 comments

Comments

@thomassedlmayer
Copy link

Hi everyone,

did anyone encounter problems when using Kivy's TextInput with an panda3d-embedded Kivy app?

I get the following error and the focus stays active after clicking an input field once and for most fields I can not even change the content.

 Traceback (most recent call last):
   File "C:\python39\lib\site-packages\panda3d_kivy\core\window.py", line 273, in update_kivy
     EventLoop.idle()
   File "C:\python39\lib\site-packages\kivy\base.py", line 383, in idle
     self.dispatch_input()
   File "C:\python39\lib\site-packages\kivy\base.py", line 334, in dispatch_input
     post_dispatch_input(*pop(0))
   File "C:\python39\lib\site-packages\kivy\base.py", line 263, in post_dispatch_input
     listener.dispatch('on_motion', etype, me)
   File "kivy\_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch
   File "C:\python39\lib\site-packages\panda3d_kivy\core\window.py", line 357, in on_motion
     super().on_motion(event_type, motion_event)
   File "C:\python39\lib\site-packages\kivy\core\window\__init__.py", line 1664, in on_motion
     self.dispatch('on_touch_up', me)
   File "kivy\_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch
   File "C:\python39\lib\site-packages\kivy\core\window\__init__.py", line 1701, in on_touch_up
     if w.dispatch('on_touch_up', touch):
   File "kivy\_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch
   File "C:\python39\lib\site-packages\kivy\uix\modalview.py", line 281, in on_touch_up
     super().on_touch_up(touch)
   File "C:\python39\lib\site-packages\kivy\uix\widget.py", line 611, in on_touch_up
     if child.dispatch('on_touch_up', touch):
   File "kivy\_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch
   File "C:\python39\lib\site-packages\kivy\uix\widget.py", line 611, in on_touch_up
     if child.dispatch('on_touch_up', touch):
   File "kivy\_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch
   File "C:\python39\lib\site-packages\kivy\uix\widget.py", line 611, in on_touch_up
     if child.dispatch('on_touch_up', touch):
   File "kivy\_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch
   File "C:\python39\lib\site-packages\kivy\uix\scrollview.py", line 968, in on_touch_up
     if self.dispatch('on_scroll_stop', touch):
   File "kivy\_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch
   File "C:\python39\lib\site-packages\kivy\uix\scrollview.py", line 1005, in on_scroll_stop
     self.simulate_touch_down(touch)
   File "C:\python39\lib\site-packages\kivy\uix\scrollview.py", line 668, in simulate_touch_down
     ret = super(ScrollView, self).on_touch_down(touch)
   File "C:\python39\lib\site-packages\kivy\uix\widget.py", line 589, in on_touch_down
     if child.dispatch('on_touch_down', touch):
   File "kivy\_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch
   File "C:\python39\lib\site-packages\kivy\uix\widget.py", line 589, in on_touch_down
     if child.dispatch('on_touch_down', touch):
   File "kivy\_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch
   File "C:\python39\lib\site-packages\kivy\uix\widget.py", line 589, in on_touch_down
     if child.dispatch('on_touch_down', touch):
   File "kivy\_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch
   File "C:\python39\lib\site-packages\kivy\uix\widget.py", line 589, in on_touch_down
     if child.dispatch('on_touch_down', touch):
   File "kivy\_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch
   File "C:\python39\lib\site-packages\kivy\uix\widget.py", line 589, in on_touch_down
     if child.dispatch('on_touch_down', touch):
   File "kivy\_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch
   File "C:\python39\lib\site-packages\kivy\uix\textinput.py", line 1541, in on_touch_down
     if super().on_touch_down(touch):
   File "C:\python39\lib\site-packages\kivy\uix\behaviors\focus.py", line 462, in on_touch_down
     self.focus = True
   File "kivy\properties.pyx", line 520, in kivy.properties.Property.__set__
   File "kivy\properties.pyx", line 567, in kivy.properties.Property.set
   File "kivy\properties.pyx", line 606, in kivy.properties.Property._dispatch
   File "kivy\_event.pyx", line 1307, in kivy._event.EventObservers.dispatch
   File "C:\python39\lib\site-packages\kivy\uix\behaviors\focus.py", line 402, in _on_focus
     self._bind_keyboard()
   File "C:\python39\lib\site-packages\kivy\uix\textinput.py", line 3011, in _bind_keyboard
     Window.bind(on_textedit=self.window_on_textedit)
 AttributeError: 'NoneType' object has no attribute 'bind'
:util(error): Exception occurred in PythonCallbackObject
 Exception ignored on calling ctypes callback function: <bound method WM_PenProvider._pen_wndProc of <kivy.input.providers.wm_pen.WM_PenProvider object at 0x0000017B0BC5F070>>

When binding the keyboard to the input field, Kivy tries to bind/unbind on_textedit to/from Window which is None in my case. In other places of kivy they usually use EventLoop.window. Though, if I just delete those lines, it works as expected except that key input is still being sent to the whole window as well. Replacing Window with EventLoop.window does not really change much compared to not having this line at all.

https://github.com/kivy/kivy/blob/01049a8f4536f42a5129e62863053c1a274e8665/kivy/uix/textinput.py#L3016
https://github.com/kivy/kivy/blob/01049a8f4536f42a5129e62863053c1a274e8665/kivy/uix/textinput.py#L3020

Am I doing something wrong?

Regs.
Thomas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant