[Bf-taskforce25] Saving keymaps

Brecht Van Lommel brecht at blender.org
Thu Sep 17 21:17:18 CEST 2009


Hi,

Ton and I had a discussion about saving keymaps. The difficulty in it
is syncing changes in Blender with the user edited keymaps. This could
be done automatic or manual.

Manual would mean that when you have a new Blender version, you can
compare the default and existing keymaps, and add new Blender keys as
you want. The advantage of this is that nothing will be changed
without you knowing it, and your keymap will always be intact when
developers change around keys. The disadvantage is that it requires
manual work to do this syncing when getting a new Blender version. The
way this would work is by saving the full keymaps to file, which will
then completely override the default keymaps.

A more automatic approach could work like this. For each default
keymap, a list of added and removed keymap items is stored, a kind of
diff. In pseudo code, a keymap lookup would work as follows:

kmi = keymap_lookup(user_add_keymap, event)
if kmi:
	return kmi

if keymap_lookup(user_remove_keymap, event):
	return NULL

return keymap_lookup(default_keymap, event)

The advantage of this is that it requires no manual syncing. A
disadvantage is that it doesn't cope well with a change in default
Blender shortcut keys. Say the user has changed G translate to M. Then
the default in Blender changes from G to ctrl+G. The result is that
now both ctrl+G and M do a translation. So then you can't as easily
take your keymap and apply it, because it depends more on the Blender
version.

We could try to solve this by checking if the operator name is the
same, but this also fails because sometimes an operator is assigned to
more than one shortcut key. And then there's also operator properties
may be different. We could try to be a bit clever about this, but not
sure how well that would work. Most applications I know have just one
key for each operator that you can assign, but here we have a more
flexible situation, where you can have both gestures, keys for some
operator, or you might change operator properties, etc.

Does anybody have ideas about how to do better, or about other apps
handling this in a good/bad way? It's kind of a general issue, suppose
you wanted to modify a menu, does that completely override the
existing one then, or do we try to be clever about syncing, accepting
it sometimes gives results you don't want?

Brecht.


More information about the Bf-taskforce25 mailing list