difining an operator as text.myoperator doesn't enable setting shortcut from context menu. #49800

Closed
opened 2016-10-20 13:27:57 +02:00 by Vilem Duha · 6 comments
Member

I have an addon where I used operators with a path text.myoperatorname.
When defining a panel with the buttons, in right-click menu there wasn't the possibility to add shortcut.
when I changed the operator path to object.myoperatorname, shortcuts are enabled.

submitting just the addon in version where it works:
macros.py
this is not working (operators with text.something)
macros_bad.py

I have an addon where I used operators with a path text.myoperatorname. When defining a panel with the buttons, in right-click menu there wasn't the possibility to add shortcut. when I changed the operator path to object.myoperatorname, shortcuts are enabled. submitting just the addon in version where it works: [macros.py](https://archive.blender.org/developer/F382151/macros.py) this is not working (operators with text.something) [macros_bad.py](https://archive.blender.org/developer/F382152/macros_bad.py)
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

Added subscriber: @VilemDuha

Added subscriber: @VilemDuha

Added subscriber: @Sergey

Added subscriber: @Sergey

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Sergey Sharybin self-assigned this 2016-10-20 14:09:44 +02:00

Thanks for the report, but it is not really a bug, but a specific behavior of how keymap matching currently works.

Thing is, when you define your operator as text.something it is supposed to be related to text editor context. Keep this in mind.

Now, when you right-click on a button Blender will first check whether shortcut is already defined for this operator within the current context, and if so will let you to edit that. This isn't your case yet.

If there is no current shortcut defined for operator yet, it'll try to deduct which exact keymap to add it. In you case because it's text.something Blender will suppose that the operator belongs to "Text" keymap. However, there is no "Text" keymap in the 3d viewport context, hence Blender will not be able to create shortcut for your button.

There might be some improvements to such guesses be done, but those are happening outside of the bug tracker.

For the time being, will suggest just to stick to a strict context specification rules, which is a good idea anyway.

Thanks for the report, but it is not really a bug, but a specific behavior of how keymap matching currently works. Thing is, when you define your operator as `text.something` it is supposed to be related to text editor context. Keep this in mind. Now, when you right-click on a button Blender will first check whether shortcut is already defined for this operator within the current context, and if so will let you to edit that. This isn't your case yet. If there is no current shortcut defined for operator yet, it'll try to deduct which exact keymap to add it. In you case because it's `text.something` Blender will suppose that the operator belongs to "Text" keymap. However, there is no "Text" keymap in the 3d viewport context, hence Blender will not be able to create shortcut for your button. There might be some improvements to such guesses be done, but those are happening outside of the bug tracker. For the time being, will suggest just to stick to a strict context specification rules, which is a good idea anyway.
Author
Member

the addon we are talking about is called Macro.

Basically it runs any internal script from a custom panel like it would be an operator(even with props :) ), so it can not have a specific context...

maybe, the solution is to define the same operator for different contexts? so I have text.run_macro, object.run_macro e.t.c.?

https://blenderartists.org/forum/showthread.php?343029-Macro-script-runner-make-your-operator-prototyping-faster

the addon we are talking about is called Macro. Basically it runs any internal script from a custom panel like it would be an operator(even with props :) ), so it can not have a specific context... maybe, the solution is to define the same operator for different contexts? so I have text.run_macro, object.run_macro e.t.c.? https://blenderartists.org/forum/showthread.php?343029-Macro-script-runner-make-your-operator-prototyping-faster
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#49800
No description provided.