You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Challenge here is that current key maps are defined with references to actual code objects.
Need to be able to refer to objects by strings instead.
I think this should JustWork™️ by adding the restriction that KeyboardActionDefinition can only have callbacks to a single object - and use getattr to find methods on that object.
i.e. interface would be: KeyboardActionDefinition.from_yaml(target_object, yaml_defn=None)
and the equivalent to_yaml would just get the string name of the functions it points at.
And the calculator example would approximately change from def create_keymap(self) -> KeyMap: to static method: create_keymap(calculator, yaml_defn=None) -> KeyMap:
Unresolved challenge:
need a way to make it easy to state which object to re-load the map for.
For global singletons this seems pretty straightforward.
Alternatively, encourage / mandate that keyboardhandlers (not just KeyboardActionDefinition) must act on a single object - then the definition of a keymap is pure and contained.
Alternatively, because keymaps are probably identical for all things of the same type (assuming only one focused at once) then a global map of unique string: keymap save name as part of a class definition means we can re-load it for any of a given class easily. e.g. class Calculator: _keymap_name = Calculator (default to class.name? - should be unique for most situations)
Second challenge:
Actually make keymaps editable. Shouldn't be too hard to just define a collection of buttons + key captures in a menu/form layout (once those are implemented!)
The text was updated successfully, but these errors were encountered:
Challenge here is that current key maps are defined with references to actual code objects.
Need to be able to refer to objects by strings instead.
I think this should JustWork™️ by adding the restriction that KeyboardActionDefinition can only have callbacks to a single object - and use
getattr
to find methods on that object.i.e. interface would be:
KeyboardActionDefinition.from_yaml(target_object, yaml_defn=None)
and the equivalent
to_yaml
would just get the string name of the functions it points at.And the calculator example would approximately change from
def create_keymap(self) -> KeyMap:
to static method:create_keymap(calculator, yaml_defn=None) -> KeyMap:
Unresolved challenge:
class Calculator: _keymap_name = Calculator
(default to class.name? - should be unique for most situations)Second challenge:
Actually make keymaps editable. Shouldn't be too hard to just define a collection of buttons + key captures in a menu/form layout (once those are implemented!)
The text was updated successfully, but these errors were encountered: