Kivy 1.9.1 issue with bind to on_keyboard of Window object for keyboard shortcuts

112 views
Skip to first unread message

Kyle Hardin

unread,
Jan 25, 2016, 4:31:19 PM1/25/16
to Kivy users support
I switch from kivy 1.9.0 to 1.9.1 and my keyboard shortcut routine no longer behaves the same. I have a class CompUI which a kivy.uix.screenmanager.Screen.

I use the following code in the init for the CompUI to bind to the keyboard:

Window.bind(on_keyboard=self.KeyboardShortcut)

I have a KeyboardShortcut method as follows:

def KeyboardShortcut(self, window, key, *args):
   try:
      # d key moves focus to tiwireDiam
      if key == 100:
         self.ids.tiwireDiam.focus = True
         return True
   except:
      return False

When using kivy 1.9.0 all of the keyboard shortcuts located in the KeyboardShortcut method moved the focus to different TextInput objects but did not actually put the keyboard shortcut character into the TextInput that was in focus. My understanding was that the "return True" in the KeyboardShortcut method caused the character to not be used by the system so it would not be placed as text in the TextInput.

In 1.9.1, this behavior has gone away and the shortcut character is being entered into the TextInput that gains focus.

Do I need to change the code for 1.9.1 to handle this differently? Also, I want to avoid using a filter on the TextInputs to look for these shortcuts. I want to handle this at the keyboard listener stage.
I’ve been on sdl2 as the backend from the beginning of development.

I am using

Windows 7 sp1, 64-bit

Python 3.4.3 (64-bit)
Kivy 1.9.1 (installed following the direction on https://kivy.org/docs/installation/installation-windows.html)

Here is a screenshot of the GUI:




I pressed the ‘o’ key to navigate to the Outside Dia. TextInput object and the program enters an ‘o’ character into the TextInput text property even though I return true in the KeyboardShortcut routine described below so that the system does not use this key press for anything other than the use in the KeyboardShortcut routine.

This was working fine this morning before I switched to using Kivy 1.9.1. Is this something I should be trying to fix this way or should I just bite the bullet and overload the insert_text method for the TextInput-based classes I have that are affected by this and filter out the shortcut keys?

I was thinking about the issue a bit more and though of the following test. If I change my code in the KeyboardShortcut routine to simply return true with no conditionals at all, shouldn’t this cause every key to fail being passed onto the system for use? Thus with print statements I could tell that I am inside my KeyboardShortcut routine when I press a key but I would never be able to get characters into the TextInput text fields.

I set my code up this way and characters still make it through and are entered into the text fields.

Here is a screen shot of my terminal window where I print the key pressed and then a blank line from my KeyboardShortcut routine.

 

While this proves the KeyboardShortcut routine was being called, the application was still entering the characters into the text field of the TextInput objects.

If I simply pass inside of the KeyboardShortcut routine then key is printed out twice for every time it is pressed.

Hope this extra information helps.

 

qua non

unread,
Jan 25, 2016, 4:38:21 PM1/25/16
to kivy-...@googlegroups.com
seems like a valid bug

--
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.
For more options, visit https://groups.google.com/d/optout.

Kyle Hardin

unread,
Feb 8, 2016, 9:55:26 AM2/8/16
to Kivy users support
If this is a valid bug what are the next steps to resolve this issue?

ZenCODE

unread,
Feb 11, 2016, 4:27:48 PM2/11/16
to Kivy users support
Please go here and create a new issue. You can include the link to this discussion.


Thanks

Reply all
Reply to author
Forward
0 new messages