Re: [Bf-committers] Substituting hot keys in an addon
On 16/06/11 06:46, Nathan Vegdahl wrote: Hello all, I am wondering if there is a best practice for substituting hotkeys via an addon. The use-case is that in Rigify I would like to allow the user to add rig-type samples via shift-A in armature edit mode. Doing so will require popping up a menu of some kind. However, currently shift-A in armature edit mode does not produce a menu, and instead immediately calls the bone_primitive_add operator, so I cannot simply insert items into the non-existent menu. What I would like to do is substitute in a menu when the Rigify addon is enabled. I am curious if there is an accepted best-practice way to do this, that is robust against custom keymaps, for example, and other corner-cases. Should I just search the active keymap for the bone_primitive_add operator, and substitute in my own? That seems like it could potentially cause problems. Alternatively I could make vanilla Blender produce a menu, and then simply insert my own items into the menu when rigify is enabled. Would that be a better way to go about it? --Nathan ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers why don't you look at how dynamic spacebar addon does it ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers
Re: [Bf-committers] Substituting hot keys in an addon
Okay, it sounds like there isn't really a nice way to do this yet, then. So I'll change vanilla Blender to pop up a menu on shift-A. That should be useful for other addons involving armatures as well. --Nathan On Thu, Jun 16, 2011 at 1:46 AM, Campbell Barton ideasma...@gmail.com wrote: On Thu, Jun 16, 2011 at 7:22 AM, Michael Fox mfoxd...@gmail.com wrote: On 16/06/11 06:46, Nathan Vegdahl wrote: Hello all, I am wondering if there is a best practice for substituting hotkeys via an addon. The use-case is that in Rigify I would like to allow the user to add rig-type samples via shift-A in armature edit mode. Doing so will require popping up a menu of some kind. However, currently shift-A in armature edit mode does not produce a menu, and instead immediately calls the bone_primitive_add operator, so I cannot simply insert items into the non-existent menu. What I would like to do is substitute in a menu when the Rigify addon is enabled. I am curious if there is an accepted best-practice way to do this, that is robust against custom keymaps, for example, and other corner-cases. Should I just search the active keymap for the bone_primitive_add operator, and substitute in my own? That seems like it could potentially cause problems. Alternatively I could make vanilla Blender produce a menu, and then simply insert my own items into the menu when rigify is enabled. Would that be a better way to go about it? --Nathan ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers why don't you look at how dynamic spacebar addon does it Dynamic spacebar is certainly not best practice since making reloading the defaults (Ctrl+N), clears the key binding. This isn't really the fault of the scripts author, we just don't have a good way to do this yet. -- - Campbell ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers
[Bf-committers] Substituting hot keys in an addon
Hello all, I am wondering if there is a best practice for substituting hotkeys via an addon. The use-case is that in Rigify I would like to allow the user to add rig-type samples via shift-A in armature edit mode. Doing so will require popping up a menu of some kind. However, currently shift-A in armature edit mode does not produce a menu, and instead immediately calls the bone_primitive_add operator, so I cannot simply insert items into the non-existent menu. What I would like to do is substitute in a menu when the Rigify addon is enabled. I am curious if there is an accepted best-practice way to do this, that is robust against custom keymaps, for example, and other corner-cases. Should I just search the active keymap for the bone_primitive_add operator, and substitute in my own? That seems like it could potentially cause problems. Alternatively I could make vanilla Blender produce a menu, and then simply insert my own items into the menu when rigify is enabled. Would that be a better way to go about it? --Nathan ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers
Re: [Bf-committers] Substituting hot keys in an addon
Hi, --- On Wed, 6/15/11, Nathan Vegdahl ces...@cessen.com wrote: What I would like to do is substitute in a menu when the Rigify addon is enabled. I am curious if there is an accepted best-practice way to do this, that is robust against custom keymaps, for example, and other corner-cases. There's no simple way to do that to cover all cases. When adding it, the best way (IMHO) is to check if that key combo is already mapped to something and overwrite if needed. Don't search by operator, that can be nasty. The issue is then where to add it. You can add it to the base keymap (blender), that will cover everyone who uses the default but not people with custom keymaps (it's arguable if that is good or bad). This is already how builtin operators work: if you have a custom keymap and you transfer it to a new version of Blender, you're missing out on all the new keymap entries and other changes. You can add it to the currently active keymap, but that will not be preserved in the saved version of a custom keymap. That is mostly only a problem when moving custom keymaps between machines, since, presumably, your extension would readd the keymap entry when registering in a subsequent session. You can add it to all keymaps and save them (except builtin obviously), but IMHO that is very nasty. That covers the case where someone might change to a different keymap in the same session. You can also just provide a menu entry (or panel) and let people add a keymap entry to their custom keymap if they want. Should I just search the active keymap for the bone_primitive_add operator, and substitute in my own? That seems like it could potentially cause problems. That has some chances of not working properly on custom keymaps, where either the operator has a new key combo or is no longer mapped to anything. Alternatively I could make vanilla Blender produce a menu, and then simply insert my own items into the menu when rigify is enabled. Would that be a better way to go about it? That's the safest way. Martin ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers