I’m working on my first pull request, and I wanted to share notes I’m taking along the way. (I think devtalk is the best place to share notes like this, but happy to post elsewhere too if there’s a better place.)
Goal: Make the “undo” button from keyboards and iPad (via sidecar) do undo actions in Blender.
Goal reference: Getting the undo button working in sidecar would address one of the issues this rightclickselect post. I commented on some of my feedback as a user who wants sidecar working, too. I’ll share a link to this in a comment hopefully, since new users can only share 2 links lol)
Keystroke → Event type → action (like “ed.undo”)
- Register “undo” keystrokes in Blender as an Event type (I could use help here)
- Change the default keybindings to map the “undo” Event type do the “ed.undo” action
For (1), I don’t really know where to start. How do keystrokes make it into the list of keystroke events? Is there a library that helps with this, or is it part of clang itself?
For (2), I’m sure I can add a default keybinding entry somewhere around here. This part seems pretty straightforward!
More background context for the OSX side at least:
- We map carbon/cocoa keystrokes to GHOST events in
- carbon is the older way, cocoa is the newer way. Carbon keycodes seem to start with
kVK_ and cocoa ones seem to start with
- I don’t see a keycode for undo in carbon – looking them up in
- Another comment suggests that carbon and cocoa share keycodes “Converts Mac raw-key codes (same for Cocoa & Carbon)” but I don’t see any reference to that from searching online.
- Maybe I could just drop in
NSUndoFunctionKey into the list that includes entries like
kVK_VolumeUp? I don’t think it’ll be quite that easy lol
And that’s where I’m at now!
Thank you LazyDodo filedescriptor and Harleya for helping point me in the right direction in blender.chat (can’t @-mention people bc I’m a new user lol)
Probably not? If you look at this code from the Chromium project, they have two different functions to convert from kVK_* (DomKeyFromKeyCode using a short keyCode), versus NS* keys DomKeyFromCharCode using a unichar char_code). The second having your NSUndoFunctionKey and NSRedoFunctionKey.