[Bf-committers] Substituting hot keys in an addon

Campbell Barton ideasman42 at gmail.com
Thu Jun 16 10:46:24 CEST 2011


On Thu, Jun 16, 2011 at 7:22 AM, Michael Fox <mfoxdogg at 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 at 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


More information about the Bf-committers mailing list