Show messages: All
1-2
3-6
From: Michael Gibson
Hi Strube - it's built into MoI's keyboard input processing that when it sees that an edit control has focus, it makes Ctrl+C, Ctrl+V, Ctrl+X and Ctrl+A execute text editing functions in that edit control rather than processing them as regular MoI command shortcuts.
But right now that does not include Ctrl+Y and Ctrl+Z mostly because MoI does not have any multi-line textarea input in any of its regular UI currently, so it just had not come up before. For v4 I could modify this to additionally look if the edit control is a multi-line control or maybe if it's marked with a particular attribute and then also have those keys handled in a similar way.
For now the only way that I can see is to have an event loop like Max shows above where you could register a command specific shortcut key and have it handled by the script itself since it will generate a UI event once it is registered. Then you could call document.execCommand( 'undo' ); to make the text edit do an undo. This may be difficult to use well though since you have to be in a modal type of event loop to do it, you won't be able to do it in a modeless dialog.
- Michael
From: ttype (STRUBE)
I've appended this, your example and added just the first line at the beginning of the script inside the body, hoping that that would change MoI's event policy. But either nothing happens or the script console is not opening at all and MoI crashes afterwards on closing.
Codemirror, which I use, btw has its' own undo/redo functionality that works when I assign a shortcut key that is not used by MoI.
code:
moi.command.registerCommandSpecificShortcutKey( "Ctrl+Z" );
while(1) {
moi.ui.commandDialog.waitForEvent();
e = moi.ui.commandDialog.event;
if ( e == 'Ctrl+Z' ) {
editor.undo();
}
}
Message 7286.5 was deleted
From: ttype (STRUBE)
I got it!
Because codemirror has its' own undo/redo functionality objects can be added to commandbar like in FullScreen.js and then I simply set up a new shortcut for CTRL+Z and Y that checks if the editor has focus.
code:
var cb = moi.ui.getUIPanel('moi://ui/CommandBar.htm');
cb.consoleDoc = document;
cb.editor = editor;
$(window).unload(function() {
delete cb.consoleDoc;
delete cb.editor;
});
code:
var cb = moi.ui.getUIPanel('moi://ui/CommandBar.htm');
if (cb.consoleDoc && cb.consoleDoc.hasFocus()) {
cb.editor.undo()
} else {
moi.command.undo();
}
So now there is a small script console with syntax highlighting, line numbers, undo/redo and bracket matching. Still not too much, but it can be found here:
https://github.com/thetumbledtype/moi3d-scripts-other/blob/master/ScriptConsole.htm
Show messages: All
1-2
3-6