[Done 2.6 Beta] Best Way To Capture And Pass On Undo/redo?

I’m trying to make a modification to the NotesRandomize script.

Basically, when in the script’s GUI I often want to UNDO. To do this, I have to forcibly click between the pattern editor and the script.

I imagine all I need to do, from a scripting point of view, is add CTRL-Z to my keyandler routine and call renoise.song():undo()

But, when trying to find out what I need to capture I run into some very OSX specific debug info.

  
rprint(key)  
  
[character] => z  
[modifiers] => command  
[name] => z  
  

So, my questions.

  • In ActionScript, you can “throw” key captures and mouse events (called event propagation). Is there such a concept in the Renoise API? What I mean here is instead of re-programming UNDO to UNDO (which is redundant) can I, instead, just throw it to the parent which reacts in the default way?

  • I imagine “command” is not a modifier on Windows or Linux, is there a more generic approach or do I have to “OR” this to be multi-platform?

Thanks.

That was what i was thinking as well… Windows programmers won’t foresee Mac users have a command-key instead of control so this means that shortcuts inside scripts that relay on these keys aren’t portable.

You can also configure shortcuts, so it doesn’t even have to be “Control + Y” for some.

What about passing keys back to Renoise instead. Something like:

  
function key_handler(dialog, key)  
 local handled = false  
 if (key.name == "my_key") then  
 -- do something, and don't pass the key to Renoise  
 handled = true  
 end  
  
 -- when not handled, let Renoise do something with the key...  
 return handled  
end  
  

Yes, this would be perfect. Is this already possible? Or are you suggesting this for a future API improvement?

Suggesting…

Maybe instead of a boolean, to make it compatible with the current API and scripts, we can instead ‘return key’ instead of ‘return true/false’?

This implies we don’t have to change current scripts.

If Renoise receives nil, do nothing. Else if NOT key, error. Else, process key?

“return key” is good. Done for the next update…

Would make life a bit easier… don’t need to double key-functionalities anymore just because my tool has keyboard focus…