Search in sources :

Example 1 with MouseDownHandler

use of com.google.gwt.event.dom.client.MouseDownHandler in project che by eclipse.

the class View method handleEvents.

private void handleEvents() {
    KeyDownHandler handler = new KeyDownHandler() {

        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (KeyboardEvent.KeyCode.ESC == event.getNativeEvent().getKeyCode()) {
                event.stopPropagation();
                event.preventDefault();
                if (delegate != null) {
                    delegate.onEscapeKey();
                }
            } else if (KeyboardEvent.KeyCode.ENTER == event.getNativeEvent().getKeyCode()) {
                event.stopPropagation();
                event.preventDefault();
                if (delegate != null) {
                    delegate.onEnterKey();
                }
            }
        }
    };
    focusPanel.addDomHandler(handler, KeyDownEvent.getType());
    closeButton.addDomHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (delegate != null) {
                delegate.onClose();
            }
            event.stopPropagation();
        }
    }, ClickEvent.getType());
    /* Don't start moving the window when clicking close button */
    closeButton.addDomHandler(new MouseDownHandler() {

        @Override
        public void onMouseDown(MouseDownEvent event) {
            event.preventDefault();
            event.stopPropagation();
        }
    }, MouseDownEvent.getType());
    MouseHandler mouseHandler = new MouseHandler();
    header.addDomHandler(mouseHandler, MouseDownEvent.getType());
    header.addDomHandler(mouseHandler, MouseUpEvent.getType());
    header.addDomHandler(mouseHandler, MouseMoveEvent.getType());
}
Also used : KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) MouseDownEvent(com.google.gwt.event.dom.client.MouseDownEvent) MouseDownHandler(com.google.gwt.event.dom.client.MouseDownHandler)

Example 2 with MouseDownHandler

use of com.google.gwt.event.dom.client.MouseDownHandler in project rstudio by rstudio.

the class ModifyKeyboardShortcutsWidget method addHandlers.

private void addHandlers() {
    table_.addCellPreviewHandler(new CellPreviewEvent.Handler<KeyboardShortcutEntry>() {

        @Override
        public void onCellPreview(CellPreviewEvent<KeyboardShortcutEntry> preview) {
            Handle shortcutsHandler = shortcuts_.disable();
            int column = preview.getColumn();
            if (column == 0)
                onNameCellPreview(preview);
            else if (column == 1)
                onShortcutCellPreview(preview);
            else if (column == 2)
                onNameCellPreview(preview);
            shortcutsHandler.close();
        }
    });
    table_.addColumnSortHandler(new ColumnSortEvent.Handler() {

        @Override
        public void onColumnSort(ColumnSortEvent event) {
            List<KeyboardShortcutEntry> data = dataProvider_.getList();
            if (event.getColumn().equals(nameColumn_))
                sort(data, 0, event.isSortAscending());
            else if (event.getColumn().equals(shortcutColumn_))
                sort(data, 1, event.isSortAscending());
            else if (event.getColumn().equals(typeColumn_))
                sort(data, 2, event.isSortAscending());
            updateData(data);
        }
    });
    // Fix a bug where clicking on a table header would also
    // select the cell at position [0, 0]. It seems that GWT's
    // DataGrid over-aggressively selects the first cell on the
    // _first_ mouse down event seen; after the first click,
    // cell selection occurs only after full mouse clicks.
    table_.addDomHandler(new MouseDownHandler() {

        @Override
        public void onMouseDown(MouseDownEvent event) {
            Element target = event.getNativeEvent().getEventTarget().cast();
            if (target.hasAttribute("__gwt_header")) {
                event.stopPropagation();
                event.preventDefault();
            }
        }
    }, MouseDownEvent.getType());
}
Also used : Element(com.google.gwt.dom.client.Element) TableRowElement(com.google.gwt.dom.client.TableRowElement) MouseDownEvent(com.google.gwt.event.dom.client.MouseDownEvent) AddinsMRUList(org.rstudio.studio.client.workbench.AddinsMRUList) List(java.util.List) ArrayList(java.util.ArrayList) ColumnSortEvent(com.google.gwt.user.cellview.client.ColumnSortEvent) MouseDownHandler(com.google.gwt.event.dom.client.MouseDownHandler) CellPreviewEvent(com.google.gwt.view.client.CellPreviewEvent) Handle(org.rstudio.core.client.command.ShortcutManager.Handle)

Aggregations

MouseDownEvent (com.google.gwt.event.dom.client.MouseDownEvent)2 MouseDownHandler (com.google.gwt.event.dom.client.MouseDownHandler)2 Element (com.google.gwt.dom.client.Element)1 TableRowElement (com.google.gwt.dom.client.TableRowElement)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)1 KeyDownHandler (com.google.gwt.event.dom.client.KeyDownHandler)1 ColumnSortEvent (com.google.gwt.user.cellview.client.ColumnSortEvent)1 CellPreviewEvent (com.google.gwt.view.client.CellPreviewEvent)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Handle (org.rstudio.core.client.command.ShortcutManager.Handle)1 AddinsMRUList (org.rstudio.studio.client.workbench.AddinsMRUList)1