[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [orion-dev] Keyboard shortcuts for custom commands in CodeEditWidget
|
Hi Libing,
here is the relevant code snippet (note that I replaced the shortcut with Ctrl-Shift-L):
require(['orion/codeEdit'], function(mCodeEdit) {
var codeEdit = new mCodeEdit();
var contents = 'var foo = "bar";';
codeEdit.create({parent: 'embeddedEditor'}).then(function(editorViewer) {
editorViewer.setContents(contents, 'application/javascript');
editorViewer.serviceRegistry.registerService('orion.edit.command', {
execute: function () {
console.log('Test');
}
}, {
name: 'Test command',
id: 'foo.bar',
key: ['l', true, true]
});
triggerMouseEvent(document.getElementById('embeddedEditor'), 'mousedown');
});
});
/**
* See http://stackoverflow.com/questions/2705583/how-to-simulate-a-click-with-javascript
*/
function triggerMouseEvent(node, eventType) {
var clickEvent = document.createEvent('MouseEvents');
clickEvent.initEvent(eventType, true, true);
node.dispatchEvent(clickEvent);
}
Regards,
Sebastian
> Am 15.12.2015 um 21:43 schrieb Libing Wang <Libing_Wang@xxxxxxxxxx>:
>
> Hi Sebastian:
> I opened bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=484435and will fixed it shortly.
> Your work around works for now but I will let you know once the bug is fixed. Please refer to the bug for more details.
>
> Regards,
> Libing
>
> P.S. Could you give me your html file? Once the bug is fixed I will remove the work around and try the fix.
>
>
>
> From: Sebastian Pahnke <pahnke.sebastian@xxxxxxxxx>
> To: Orion developer discussions <orion-dev@xxxxxxxxxxx>
> Date: 12/15/2015 04:08 AM
> Subject: [orion-dev] Keyboard shortcuts for custom commands in CodeEditWidget
> Sent by: orion-dev-bounces@xxxxxxxxxxx
>
>
>
> Hi,
>
> I’m using the command service (https://wiki.eclipse.org/Orion/Documentation/Developer_Guide/Plugging_into_the_editor#orion.edit.command) to register commands with the shortcuts Ctrl + and Ctrl -. The registration happens after editor creation in the 'then'-callback.
>
> Unfortunately, the command is executed from the second time on only (i.e. first the browser zoom is triggered, then on second press my command is triggered). I tracked this behavior into the createEditor function in editorSetup.js where the setActiveEditorView function is invoked after a mouse click or key up event. This function has to be invoked for the shortcuts to be active. I currently worked around this problem by triggering a mouse click event after editor creation. Is there a proper way of dealing with this situation?
>
> Regards,
> Sebastian
>
> P.S.: It doesn’t help to register the command before the codeEdit.create() call.
>
>
> _______________________________________________
> orion-dev mailing list
> orion-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/orion-dev
>
> _______________________________________________
> orion-dev mailing list
> orion-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/orion-dev