Search in sources :

Example 1 with NativeEvent

use of org.gwtproject.dom.client.NativeEvent in project gwtproject by treblereel.

the class RadioButtonTest method doClick.

private void doClick(Element elm) {
    NativeEvent e = Document.get().createMouseDownEvent(0, 25, 25, 25, 25, false, false, false, false, NativeEvent.BUTTON_LEFT);
    elm.dispatchEvent(e);
    e = Document.get().createMouseUpEvent(0, 25, 25, 25, 25, false, false, false, false, NativeEvent.BUTTON_LEFT);
    elm.dispatchEvent(e);
    e = Document.get().createClickEvent(0, 25, 25, 25, 25, false, false, false, false);
    elm.dispatchEvent(e);
}
Also used : NativeEvent(org.gwtproject.dom.client.NativeEvent)

Example 2 with NativeEvent

use of org.gwtproject.dom.client.NativeEvent in project gwtproject by treblereel.

the class HyperlinkTest method testLinkTraversal.

public void testLinkTraversal() {
    final String testHistoryToken = TEST_HISTORY_TOKEN;
    Hyperlink link = new Hyperlink("foobar", testHistoryToken);
    HandlerRegistration registration = null;
    try {
        RootPanel.get().add(link);
        registration = History.addValueChangeHandler(new ValueChangeHandler<String>() {

            @Override
            public void onValueChange(ValueChangeEvent<String> event) {
                assertEquals(testHistoryToken, event.getValue());
                assertEquals(testHistoryToken, History.getToken());
            }
        });
        Document document = Document.get();
        NativeEvent event = document.createClickEvent(1, 0, 0, 0, 0, false, false, false, false);
        link.getElement().dispatchEvent(event);
    } finally {
        RootPanel.get().remove(link);
        if (registration != null) {
            registration.removeHandler();
        }
    }
}
Also used : HandlerRegistration(org.gwtproject.event.shared.HandlerRegistration) ValueChangeEvent(org.gwtproject.event.logical.shared.ValueChangeEvent) ValueChangeHandler(org.gwtproject.event.logical.shared.ValueChangeHandler) Document(org.gwtproject.dom.client.Document) NativeEvent(org.gwtproject.dom.client.NativeEvent)

Example 3 with NativeEvent

use of org.gwtproject.dom.client.NativeEvent in project gwtproject by treblereel.

the class MenuBarTest method testEscapeKey.

public void testEscapeKey() {
    // Create a menu bar with children.
    MenuBar l0 = new MenuBar();
    l0.setAutoOpen(true);
    MenuBar l1 = new MenuBar();
    l1.setAutoOpen(true);
    MenuBar l2 = new MenuBar();
    l2.setAutoOpen(true);
    MenuItem item2 = l2.addItem("l2", BLANK_COMMAND);
    MenuItem item1 = l1.addItem("l1", l2);
    MenuItem item0 = l0.addItem("l0", l1);
    RootPanel.get().add(l0);
    // Open l2.
    l0.itemOver(item0, true);
    l1.itemOver(item1, true);
    l2.itemOver(item2, true);
    assertTrue(l0.getPopup().isShowing());
    assertEquals(item0, l0.getSelectedItem());
    assertTrue(l1.getPopup().isShowing());
    assertEquals(item1, l1.getSelectedItem());
    // Escape from the menu.
    NativeEvent event = Document.get().createKeyDownEvent(false, false, false, false, KeyCodes.KEY_ESCAPE);
    l1.getElement().dispatchEvent(event);
/*    assertNull(l0.getPopup());
    assertNull(l0.getSelectedItem());
    assertNull(l1.getPopup());*/
}
Also used : NativeEvent(org.gwtproject.dom.client.NativeEvent)

Example 4 with NativeEvent

use of org.gwtproject.dom.client.NativeEvent in project gwtproject by treblereel.

the class DefaultSelectionEventManagerTest method testHandleSelectionEventToggle.

public void testHandleSelectionEventToggle() {
    org.gwtproject.view.client.SingleSelectionModel<String> model = new SingleSelectionModel<String>();
    display.setSelectionModel(model);
    model.setSelected("test 0", true);
    // Toggle a different value.
    NativeEvent nativeEvent = Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false);
    org.gwtproject.view.client.CellPreviewEvent<String> event = new CellPreviewEvent<String>(nativeEvent, display, new Context(1, 0, null), "test 1", false, false);
    manager.handleSelectionEvent(event, SelectAction.TOGGLE, model);
    assertEquals("test 1", model.getSelectedObject());
    // Toggle the same value.
    manager.handleSelectionEvent(event, SelectAction.TOGGLE, model);
    assertNull(model.getSelectedObject());
}
Also used : Context(org.gwtproject.cell.client.Cell.Context) NativeEvent(org.gwtproject.dom.client.NativeEvent)

Example 5 with NativeEvent

use of org.gwtproject.dom.client.NativeEvent in project gwtproject by treblereel.

the class DefaultSelectionEventManagerTest method testHandleSelectionEventSelect.

public void testHandleSelectionEventSelect() {
    org.gwtproject.view.client.SingleSelectionModel<String> model = new org.gwtproject.view.client.SingleSelectionModel<String>();
    display.setSelectionModel(model);
    model.setSelected("test 0", true);
    // Select the same value.
    NativeEvent nativeEvent = Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false);
    org.gwtproject.view.client.CellPreviewEvent<String> event = new org.gwtproject.view.client.CellPreviewEvent<String>(nativeEvent, display, new Context(0, 0, null), "test 0", false, false);
    manager.handleSelectionEvent(event, SelectAction.SELECT, model);
    assertEquals("test 0", model.getSelectedObject());
    // Select a different value.
    event = new org.gwtproject.view.client.CellPreviewEvent<String>(nativeEvent, display, new Context(1, 0, null), "test 1", false, false);
    manager.handleSelectionEvent(event, SelectAction.SELECT, model);
    assertEquals("test 1", model.getSelectedObject());
}
Also used : Context(org.gwtproject.cell.client.Cell.Context) NativeEvent(org.gwtproject.dom.client.NativeEvent)

Aggregations

NativeEvent (org.gwtproject.dom.client.NativeEvent)60 Element (org.gwtproject.dom.client.Element)15 Context (org.gwtproject.cell.client.Cell.Context)9 InputElement (org.gwtproject.dom.client.InputElement)7 Event (org.gwtproject.user.client.Event)6 ViewData (org.gwtproject.cell.client.EditTextCell.ViewData)4 ValueUpdater (org.gwtproject.cell.client.ValueUpdater)3 ValueChangeEvent (org.gwtproject.event.logical.shared.ValueChangeEvent)3 Timer (org.gwtproject.timer.client.Timer)3 EventListener (org.gwtproject.user.client.EventListener)3 ArrayList (java.util.ArrayList)2 DivElement (org.gwtproject.dom.client.DivElement)2 ImageElement (org.gwtproject.dom.client.ImageElement)2 ClickEvent (org.gwtproject.event.dom.client.ClickEvent)2 ClickHandler (org.gwtproject.event.dom.client.ClickHandler)2 Event (elemental2.dom.Event)1 Date (java.util.Date)1 TextCell (org.gwtproject.cell.client.TextCell)1 Document (org.gwtproject.dom.client.Document)1 DomEvent (org.gwtproject.event.dom.client.DomEvent)1