Hi,

--- On Wed, 6/15/11, Nathan Vegdahl <[email protected]> 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
[email protected]
http://lists.blender.org/mailman/listinfo/bf-committers

Reply via email to