Unpropagate Document hooks

Hello all,

I just want to code a keyboard hook when I’m working on the Sc IDE.
So I just coded that

Document.globalKeyDownAction_{ arg self, key, mod;
	var ret = true;
	if (mod.isAlt){
			$g, {
				ret = false;

It works, and just I would want to know if we could avoid the ‘typing g’ effect. That’s all !

Thank you

Maybe this is clear to everyone else, but what do you mean with the “typing g” effect?

sorry I wasnt clear. I meant the fact that the letter is typed (since it’s a keyboard hook)

Unfortunately it’s not really avoidable - the IDE sends a key down message to sclang so your function gets hit, but it’s one way communication. You can’t do the thing that you can ordinarily do with e.g. keyboard events where you can mark them as accepted or not to stop propagation.


so as a little hack, one could add this :

diff --git a/editors/sc-ide/widgets/code_editor/editor.cpp b/editors/sc-ide/widgets/code_editor/editor.cpp
index 30d2b2fa5..8914ee210 100644
--- a/editors/sc-ide/widgets/code_editor/editor.cpp
+++ b/editors/sc-ide/widgets/code_editor/editor.cpp
@@ -528,7 +528,11 @@ void GenericCodeEditor::keyPressEvent(QKeyEvent * event)
-            QPlainTextEdit::keyPressEvent(event);
+					if (Main::documentManager()->globalKeyDownActionEnabled() &&
+							(event->modifiers() == Qt::ALT &&
+							 event->key() == Qt::Key_G)) {} else {
+						QPlainTextEdit::keyPressEvent(event);						
+					}

would it not be a good idea to add one or two predefined shortcuts to trigger custom code ? One for loading files, and another to play a Pdef ?? I was always thinking creating some kind of Pdef.main.