public void fireKeyPressEvent(HasHandlers widget) { DomEvent.fireNativeEvent(Document.get().createKeyPressEvent(false, false, false, false, 1), widget); }
public void fireKeyPressEvent(HasHandlers widget) { DomEvent.fireNativeEvent(Document.get().createKeyPressEvent(false, false, false, false, 1), widget); }
/** Ensure that when other keys are pressed, they are not passed to the action. */ public void testAlternativeKeyPress() { KeyBindingRegistry bindings = new KeyBindingRegistry(); callTracker = 0; EditorAction testAction = new EditorAction() { public void execute(EditorContext context) { callTracker++; } }; bindings.registerAction(KeyCombo.ORDER_G, testAction); EditorImpl editor = createEditor(bindings); // This event is not ORDER_G, it has other accelerators thrown in. Event rawEvent = Document.get().createKeyPressEvent( true, true, true, false, G_CODE, G_CODE).cast(); editor.onJavaScriptEvent("keypress", rawEvent); assertEquals("Callback action called on unregistered keypress", callTracker, 0); }
/** Ensure that when other keys are pressed, they are not passed to the action. */ public void testAlternativeKeyPress() { KeyBindingRegistry bindings = new KeyBindingRegistry(); callTracker = 0; EditorAction testAction = new EditorAction() { public void execute(EditorContext context) { callTracker++; } }; bindings.registerAction(KeyCombo.ORDER_G, testAction); EditorImpl editor = createEditor(bindings); // This event is not ORDER_G, it has other accelerators thrown in. Event rawEvent = Document.get().createKeyPressEvent( true, true, true, false, G_CODE, G_CODE).cast(); editor.onJavaScriptEvent("keypress", rawEvent); assertEquals("Callback action called on unregistered keypress", callTracker, 0); }
/** * Ensure that an action bound to ORDER_G is executed when the appropriate JS keypress * event is fired at the editor. */ public void testKeyBinding() { KeyBindingRegistry bindings = new KeyBindingRegistry(); callTracker = 0; EditorAction testAction = new EditorAction() { public void execute(EditorContext context) { callTracker++; } }; bindings.registerAction(KeyCombo.ORDER_G, testAction); EditorImpl editor = createEditor(bindings); // 103 = g, this event = CTRL_G which is bound to ORDER_G by the EventWrapper Event rawEvent = Document.get().createKeyPressEvent( true, false, false, false, G_CODE, G_CODE).cast(); editor.onJavaScriptEvent("keypress", rawEvent); assertEquals("Callback action not called on registered keypress", callTracker, 1); }
/** * Ensure that an action bound to ORDER_G is executed when the appropriate JS keypress * event is fired at the editor. */ public void testKeyBinding() { KeyBindingRegistry bindings = new KeyBindingRegistry(); callTracker = 0; EditorAction testAction = new EditorAction() { public void execute(EditorContext context) { callTracker++; } }; bindings.registerAction(KeyCombo.ORDER_G, testAction); EditorImpl editor = createEditor(bindings); // 103 = g, this event = CTRL_G which is bound to ORDER_G by the EventWrapper Event rawEvent = Document.get().createKeyPressEvent( true, false, false, false, G_CODE, G_CODE).cast(); editor.onJavaScriptEvent("keypress", rawEvent); assertEquals("Callback action not called on registered keypress", callTracker, 1); }
/** * Ensure that new keybindings are used after changing them in the editor. */ public void testReregistrationKeyBinding() { KeyBindingRegistry bindings = new KeyBindingRegistry(); callTracker = 0; EditorAction testAction = new EditorAction() { public void execute(EditorContext context) { callTracker++; } }; bindings.registerAction(KeyCombo.ORDER_G, testAction); EditorImpl editor = createEditor(bindings); Event rawEvent = Document.get().createKeyPressEvent( true, false, false, false, G_CODE, G_CODE).cast(); editor.onJavaScriptEvent("keypress", rawEvent); // callTracker should be 1 assuming the test above passes bindings.removeAction(KeyCombo.ORDER_G); initEditor(editor, Editor.ROOT_REGISTRIES, bindings); editor.onJavaScriptEvent("keypress", rawEvent); assertEquals("Callback action called on deregistered keypress", callTracker, 1); }
/** * Ensure that new keybindings are used after changing them in the editor. */ public void testReregistrationKeyBinding() { KeyBindingRegistry bindings = new KeyBindingRegistry(); callTracker = 0; EditorAction testAction = new EditorAction() { public void execute(EditorContext context) { callTracker++; } }; bindings.registerAction(KeyCombo.ORDER_G, testAction); EditorImpl editor = createEditor(bindings); Event rawEvent = Document.get().createKeyPressEvent( true, false, false, false, G_CODE, G_CODE).cast(); editor.onJavaScriptEvent("keypress", rawEvent); // callTracker should be 1 assuming the test above passes bindings.removeAction(KeyCombo.ORDER_G); initEditor(editor, Editor.ROOT_REGISTRIES, bindings); editor.onJavaScriptEvent("keypress", rawEvent); assertEquals("Callback action called on deregistered keypress", callTracker, 1); }
dispatchEvent(document.createKeyDownEvent(false, false, false, false, keys[0])); if ((eventbits | Event.ONKEYPRESS) == Event.ONKEYPRESS) dispatchEvent(document.createKeyPressEvent(false, false, false, false, keys[0], 0)); if ((eventbits | Event.ONKEYUP) == Event.ONKEYUP) dispatchEvent(document.createKeyUpEvent(false, false, false, false, keys[0]));