private void registerClickHandler() { HandlerRegistration registration = text.addNodeMouseClickHandler(event -> { if (null != textClickEventViewHandler) { eventHandlerManager.get().skipClickHandler(); final TextClickEvent e = new TextClickEvent(event.getX(), event.getY(), event.getMouseEvent().getClientX(), event.getMouseEvent().getClientY()); textClickEventViewHandler.handle(e); eventHandlerManager.get().restoreClickHandler(); } }); eventHandlerManager.get().addHandlersRegistration(ViewEventType.TEXT_CLICK, registration); }
@Override public void onNodeMouseClick(final NodeMouseClickEvent event) { m_control.onMouseClick(new MouseEvent(event.getX(), event.getY(), event.isShiftKeyDown(), event.isAltKeyDown(), event.isControlKeyDown())); }
@Override public void onNodeMouseClick(final NodeMouseClickEvent event) { m_control.onMouseClick(new MouseEvent(event.getX(), event.getY(), event.isShiftKeyDown(), event.isAltKeyDown(), event.isControlKeyDown())); }
@Override public void onNodeMouseClick(final NodeMouseClickEvent event) { m_control.onMouseClick(new MouseEvent(event.getX(), event.getY(), event.isShiftKeyDown(), event.isAltKeyDown(), event.isControlKeyDown())); }
@Test public void checkHeaderSelectionDelegation() { when(gridWidget.selectHeaderCell(eq(relativeLocation), anyBoolean(), anyBoolean())).thenReturn(true); when(gridWidget.isSelected()).thenReturn(false); when(gridWidget.isVisible()).thenReturn(true); when(event.getX()).thenReturn(100); when(event.getY()).thenReturn(200); handler.onNodeMouseEvent(gridWidget, relativeLocation, Optional.of(0), Optional.of(1), Optional.empty(), Optional.empty(), event); verify(handler, times(1)).handleHeaderCell(eq(gridWidget), eq(relativeLocation), eq(0), eq(1), eq(event)); verify(gridWidget, times(1)).selectHeaderCell(eq(relativeLocation), eq(false), eq(false)); verify(layer).batch(); verify(selectionManager).select(eq(gridWidget)); }
@Test public void checkHeaderSelectionDelegation() { when(gridWidget.selectHeaderCell(eq(relativeLocation), anyBoolean(), anyBoolean())).thenReturn(true); when(gridWidget.isSelected()).thenReturn(false); when(gridWidget.isVisible()).thenReturn(true); when(event.getX()).thenReturn(100); when(event.getY()).thenReturn(200); handler.onNodeMouseEvent(gridWidget, relativeLocation, Optional.of(0), Optional.of(1), Optional.empty(), Optional.empty(), event); verify(handler, times(1)).handleHeaderCell(eq(gridWidget), eq(relativeLocation), eq(0), eq(1), eq(event)); verify(gridWidget, times(1)).selectHeaderCell(eq(relativeLocation), eq(false), eq(false)); verify(layer).batch(); verify(selectionManager).select(eq(gridWidget)); }
when(event.getY()).thenReturn(100);
@Test public void checkBodySelectionDelegation() { when(gridWidget.selectCell(eq(relativeLocation), anyBoolean(), anyBoolean())).thenReturn(true); when(gridWidget.isSelected()).thenReturn(false); when(gridWidget.isVisible()).thenReturn(true); when(event.getX()).thenReturn(100); when(event.getY()).thenReturn(200); handler.onNodeMouseEvent(gridWidget, relativeLocation, Optional.empty(), Optional.empty(), Optional.of(0), Optional.of(1), event); verify(handler, times(1)).handleBodyCell(eq(gridWidget), eq(relativeLocation), eq(0), eq(1), eq(event)); verify(gridWidget, times(1)).selectCell(eq(relativeLocation), eq(false), eq(false)); verify(layer).batch(); verify(selectionManager).select(eq(gridWidget)); } }
@Test public void selectVisibleGridHeaderNonLinkedColumn() { when(gridWidget.isVisible()).thenReturn(true); when(event.getX()).thenReturn(100); when(event.getY()).thenReturn(100); when(gridWidget.getLocation()).thenReturn(new Point2D(100, 100)); when(uiColumn.isLinked()).thenReturn(false); final BaseGridRendererHelper.ColumnInformation ci = new BaseGridRendererHelper.ColumnInformation(uiColumn, 0, 0); when(helper.getColumnInformation(any(Double.class))).thenReturn(ci); handler.onNodeMouseEvent(gridWidget, relativeLocation, Optional.of(0), Optional.of(0), Optional.empty(), Optional.empty(), event); verify(handler, times(1)).handleHeaderCell(eq(gridWidget), eq(relativeLocation), eq(0), eq(0), eq(event)); verify(selectionManager, never()).select(any(GridWidget.class)); verify(selectionManager, never()).selectLinkedColumn(eq(uiColumn)); }
@Test public void checkBodySelectionDelegation() { when(gridWidget.selectCell(eq(relativeLocation), anyBoolean(), anyBoolean())).thenReturn(true); when(gridWidget.isSelected()).thenReturn(false); when(gridWidget.isVisible()).thenReturn(true); when(event.getX()).thenReturn(100); when(event.getY()).thenReturn(200); handler.onNodeMouseEvent(gridWidget, relativeLocation, Optional.empty(), Optional.empty(), Optional.of(0), Optional.of(1), event); verify(handler, times(1)).handleBodyCell(eq(gridWidget), eq(relativeLocation), eq(0), eq(1), eq(event)); verify(gridWidget, times(1)).selectCell(eq(relativeLocation), eq(false), eq(false)); verify(layer).batch(); verify(selectionManager).select(eq(gridWidget)); } }
@Test public void selectVisibleGridHeaderNonLinkedColumn() { when(gridWidget.isVisible()).thenReturn(true); when(event.getX()).thenReturn(100); when(event.getY()).thenReturn(100); when(gridWidget.getLocation()).thenReturn(new Point2D(100, 100)); when(uiColumn.isLinked()).thenReturn(false); final BaseGridRendererHelper.ColumnInformation ci = new BaseGridRendererHelper.ColumnInformation(uiColumn, 0, 0); when(helper.getColumnInformation(any(Double.class))).thenReturn(ci); handler.onNodeMouseEvent(gridWidget, relativeLocation, Optional.of(0), Optional.of(0), Optional.empty(), Optional.empty(), event); verify(handler, times(1)).handleHeaderCell(eq(gridWidget), eq(relativeLocation), eq(0), eq(0), eq(event)); verify(selectionManager, never()).select(any(GridWidget.class)); verify(selectionManager, never()).selectLinkedColumn(eq(uiColumn)); }
when(event.getY()).thenReturn(100);
@Override public void onNodeMouseClick(final NodeMouseClickEvent event) { // temporarily remove the rect, use findAt to find the underlying shape and trigger the click event if (event.isButtonLeft()) { m_selectionManager.getSelectionShape().removeFromParent(); m_selectionManager.m_layer.draw(); Node<?> node = m_selectionManager.m_layer.getViewport().findShapeAtPoint(event.getX(), event.getY()); m_selectionManager.m_layer.add(m_selectionManager.getSelectionShape()); m_selectionManager.m_layer.draw(); while (node != null) { if (node.isEventHandled(event.getAssociatedType())) { node.fireEvent(event); break; } node = node.getParent(); } } }
@Override public void onNodeMouseClick(final NodeMouseClickEvent event) { // temporarily remove the rect, use findAt to find the underlying shape and trigger the click event if (event.isButtonLeft()) { m_selectionManager.getSelectionShape().removeFromParent(); m_selectionManager.m_layer.draw(); Node<?> node = m_selectionManager.m_layer.getViewport().findShapeAtPoint(event.getX(), event.getY()); m_selectionManager.m_layer.add(m_selectionManager.getSelectionShape()); m_selectionManager.m_layer.draw(); while (node != null) { if (node.isEventHandled(event.getAssociatedType())) { node.fireEvent(event); break; } node = node.getParent(); } } }
@Override public void onNodeMouseClick(final NodeMouseClickEvent event) { // temporarily remove the rect, use findAt to find the underlying shape and trigger the click event if (event.isButtonLeft()) { m_selectionManager.getSelectionShape().removeFromParent(); m_selectionManager.m_layer.draw(); Node<?> node = m_selectionManager.m_layer.getViewport().findShapeAtPoint(event.getX(), event.getY()); m_selectionManager.m_layer.add(m_selectionManager.getSelectionShape()); m_selectionManager.m_layer.draw(); while (node != null) { if (node.isEventHandled(event.getAssociatedType())) { node.fireEvent(event); break; } node = node.getParent(); } } }
@Override public V addButton(Glyph glyph, String title, Consumer<MouseClickEvent> clickEventConsumer) { final ButtonItem button = toolboxFactory.buttons() .button(renderGlyph(glyph, getGlyphSize())) .decorate(createDecorator()) .tooltip(tooltip.createItem(title)) .onMouseEnter(event -> onMouseEnter()) .onMouseExit(event -> onMouseExit()) .onClick(event -> clickEventConsumer.accept(new MouseClickEvent(event.getX(), event.getY(), event.getMouseEvent() .getClientX(), event.getMouseEvent() .getClientY()))); addButton(button); return cast(); }
restoreClickHandler(); final int x = nodeMouseClickEvent.getX(); final int y = nodeMouseClickEvent.getY(); final int clientX = nodeMouseClickEvent.getMouseEvent().getClientX(); final int clientY = nodeMouseClickEvent.getMouseEvent().getClientY();