Cannot define Alt-E keybinding in Text Editor window #32437

Closed
opened 2012-08-29 03:19:03 +02:00 by Lawrence D'Oliveiro · 4 comments

%%%This addon https://github.com/ldo/edit_external_for_blender adds a new command to the “Text” menu in the Text Editor window. It also tries to define a keyboard shortcut for that menu item. The menu item displays in the menu, together with its keyboard shortcut, just fine. The menu item also works fine when selected with the mouse. However, the keyboard shortcut only works when there is NO text block currently open; otherwise, it ends up inserting the letter “e” into the text block.

Am I doing something wrong? If I was, I wouldn't expect the shortcut to show up or work at all.

Tested with a recent Blender 2.63.17 build.%%%

%%%This addon https://github.com/ldo/edit_external_for_blender adds a new command to the “Text” menu in the Text Editor window. It also tries to define a keyboard shortcut for that menu item. The menu item displays in the menu, together with its keyboard shortcut, just fine. The menu item also works fine when selected with the mouse. However, the keyboard shortcut only works when there is NO text block currently open; otherwise, it ends up inserting the letter “e” into the text block. Am I doing something wrong? If I was, I wouldn't expect the shortcut to show up or work at all. Tested with a recent Blender 2.63.17 build.%%%

Changed status to: 'Open'

Changed status to: 'Open'
Member

%%%Confirmed.

After having a bit of a poke around, I think what's happening is that since keymaps are evaluated in sequential order (first match wins) and your hotkey is getting added on to the builtin one for the Text Editor, the "KM_TEXTINPUT, KM_ALL, KM_ALL" keymaps at the end (i.e. a catch-all for anything that looks remotely like text but hasn't been caught as a command) fires. Hence, the event never gets to your operator.

I've added a fix to svn. You'll need to modify your script (specifically the keymap.new() call) to include "head=True", which makes your keymap item get added at the start of the keymap to avoid the problems at the end.%%%

%%%Confirmed. After having a bit of a poke around, I think what's happening is that since keymaps are evaluated in sequential order (first match wins) and your hotkey is getting added on to the builtin one for the Text Editor, the "KM_TEXTINPUT, KM_ALL, KM_ALL" keymaps at the end (i.e. a catch-all for anything that looks remotely like text but hasn't been caught as a command) fires. Hence, the event never gets to your operator. I've added a fix to svn. You'll need to modify your script (specifically the keymap.new() call) to include "head=True", which makes your keymap item get added at the start of the keymap to avoid the problems at the end.%%%
Member

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

%%%Thank you for that. I have done the change and confirmed that it works.

As an aside, I can't help thinking that a lot of these detailed comments that you put in commit messages belong in the source code, not (just) in the commit log. Because a future maintainer might wonder why things are done a certain way, and will almost certainly not think of looking in the commit history for items affecting those source lines for more info.%%%

%%%Thank you for that. I have done the change and confirmed that it works. As an aside, I can't help thinking that a lot of these detailed comments that you put in commit messages belong in the source code, not (just) in the commit log. Because a future maintainer might wonder why things are done a certain way, and will almost certainly not think of looking in the commit history for items affecting those source lines for more info.%%%
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#32437
No description provided.