use of com.ait.lienzo.client.core.event.NodeMouseEnterEvent in project lienzo-core by ahome-it.
the class LienzoHandlerManager method doCheckEnterExitShape.
// This will also return the shape under the cursor, for some optimization on Mouse Move
@SuppressWarnings("unchecked")
private final Shape<?> doCheckEnterExitShape(final INodeXYEvent event) {
final int x = event.getX();
final int y = event.getY();
final Shape<?> shape = findShapeAtPoint(x, y);
if (shape != null) {
final IPrimitive<?> prim = shape.asPrimitive();
if (null != m_over_prim) {
if (prim != m_over_prim) {
if (m_over_prim.isEventHandled(NodeMouseExitEvent.getType())) {
if (event instanceof AbstractNodeHumanInputEvent) {
m_over_prim.fireEvent(new NodeMouseExitEvent(((AbstractNodeHumanInputEvent<MouseEvent<?>, ?>) event).getHumanInputEvent(), x, y));
} else {
m_over_prim.fireEvent(new NodeMouseExitEvent(null, x, y));
}
}
}
}
if (prim != m_over_prim) {
if ((null != prim) && (prim.isEventHandled(NodeMouseEnterEvent.getType()))) {
if (event instanceof AbstractNodeHumanInputEvent) {
prim.fireEvent(new NodeMouseEnterEvent(((AbstractNodeHumanInputEvent<MouseEvent<?>, ?>) event).getHumanInputEvent(), x, y));
} else {
prim.fireEvent(new NodeMouseEnterEvent(null, x, y));
}
}
m_over_prim = prim;
}
} else {
doCancelEnterExitShape(event);
}
return shape;
}
use of com.ait.lienzo.client.core.event.NodeMouseEnterEvent in project kie-wb-common by kiegroup.
the class AbstractActionsToolboxViewTest method testAddButton.
@SuppressWarnings("unchecked")
protected void testAddButton(final String title) {
// Verify tootlip.
verify(toolboxTooltip, times(1)).createItem(eq(title));
verify(buttonItem, times(1)).tooltip(any());
// Verify mouse enter.
final ArgumentCaptor<NodeMouseEnterHandler> enterHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseEnterHandler.class);
verify(buttonItem, times(1)).onMouseEnter(enterHandlerArgumentCaptor.capture());
final NodeMouseEnterHandler enterHandler = enterHandlerArgumentCaptor.getValue();
final NodeMouseEnterEvent mouseEnterEvent = mock(NodeMouseEnterEvent.class);
enterHandler.onNodeMouseEnter(mouseEnterEvent);
verify(canvasView, times(1)).setCursor(eq(AbstractCanvas.Cursors.POINTER));
// Verify mouse exit.
final ArgumentCaptor<NodeMouseExitHandler> exitHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseExitHandler.class);
verify(buttonItem, times(1)).onMouseExit(exitHandlerArgumentCaptor.capture());
final NodeMouseExitHandler exitHandler = exitHandlerArgumentCaptor.getValue();
final NodeMouseExitEvent mouseExitEvent = mock(NodeMouseExitEvent.class);
exitHandler.onNodeMouseExit(mouseExitEvent);
verify(canvasView, times(1)).setCursor(eq(AbstractCanvas.Cursors.DEFAULT));
}
use of com.ait.lienzo.client.core.event.NodeMouseEnterEvent in project kie-wb-common by kiegroup.
the class AbstractActionsToolboxViewTest method testAddButton.
@SuppressWarnings("unchecked")
protected void testAddButton(final Consumer<MouseClickEvent> clickEventConsumer) {
// Verify tootlip.
verify(toolboxTooltip, times(1)).createItem(eq("title1"));
verify(buttonItem, times(1)).tooltip(any(TooltipItem.class));
// Verify mouse enter.
final ArgumentCaptor<NodeMouseEnterHandler> enterHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseEnterHandler.class);
verify(buttonItem, times(1)).onMouseEnter(enterHandlerArgumentCaptor.capture());
final NodeMouseEnterHandler enterHandler = enterHandlerArgumentCaptor.getValue();
final NodeMouseEnterEvent mouseEnterEvent = mock(NodeMouseEnterEvent.class);
enterHandler.onNodeMouseEnter(mouseEnterEvent);
verify(canvasView, times(1)).setCursor(eq(AbstractCanvas.Cursors.POINTER));
// Verify mouse exit.
final ArgumentCaptor<NodeMouseExitHandler> exitHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseExitHandler.class);
verify(buttonItem, times(1)).onMouseExit(exitHandlerArgumentCaptor.capture());
final NodeMouseExitHandler exitHandler = exitHandlerArgumentCaptor.getValue();
final NodeMouseExitEvent mouseExitEvent = mock(NodeMouseExitEvent.class);
exitHandler.onNodeMouseExit(mouseExitEvent);
verify(canvasView, times(1)).setCursor(eq(AbstractCanvas.Cursors.AUTO));
// Verify mouse click.
final ArgumentCaptor<NodeMouseClickHandler> clickHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseClickHandler.class);
verify(buttonItem, times(1)).onClick(clickHandlerArgumentCaptor.capture());
final NodeMouseClickHandler clickHandler = clickHandlerArgumentCaptor.getValue();
final NodeMouseClickEvent mouseClickEvent = mock(NodeMouseClickEvent.class);
when(mouseClickEvent.getMouseEvent()).thenReturn(mock(MouseEvent.class));
clickHandler.onNodeMouseClick(mouseClickEvent);
verify(clickEventConsumer, times(1)).accept(any(MouseClickEvent.class));
}
use of com.ait.lienzo.client.core.event.NodeMouseEnterEvent in project kie-wb-common by kiegroup.
the class ViewEventHandlerManagerTest method testMouseEnterHandler.
@Test
@SuppressWarnings("unchecked")
public void testMouseEnterHandler() {
final ViewHandler<ViewEvent> clickHandler = mock(ViewHandler.class);
final HandlerRegistration handlerRegistration = mock(HandlerRegistration.class);
when(shape.addNodeMouseEnterHandler(any(NodeMouseEnterHandler.class))).thenReturn(handlerRegistration);
tested.addHandler(ViewEventType.MOUSE_ENTER, clickHandler);
final ArgumentCaptor<NodeMouseEnterHandler> clickHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseEnterHandler.class);
verify(shape, times(1)).addNodeMouseEnterHandler(clickHandlerArgumentCaptor.capture());
final NodeMouseEnterHandler nodeCLickHandler = clickHandlerArgumentCaptor.getValue();
final NodeMouseEnterEvent clickEvent = mock(NodeMouseEnterEvent.class);
final MouseEvent mouseEvent = mock(MouseEvent.class);
final int x = 102;
final int y = 410;
when(clickEvent.getX()).thenReturn(x);
when(clickEvent.getY()).thenReturn(y);
when(clickEvent.isShiftKeyDown()).thenReturn(true);
when(clickEvent.isAltKeyDown()).thenReturn(true);
when(clickEvent.isMetaKeyDown()).thenReturn(true);
when(clickEvent.getMouseEvent()).thenReturn(mouseEvent);
when(mouseEvent.getClientX()).thenReturn(x);
when(mouseEvent.getClientY()).thenReturn(y);
nodeCLickHandler.onNodeMouseEnter(clickEvent);
final ArgumentCaptor<ViewEvent> eventArgumentCaptor = ArgumentCaptor.forClass(ViewEvent.class);
verify(clickHandler, times(1)).handle(eventArgumentCaptor.capture());
final MouseEnterEvent viewEvent = (MouseEnterEvent) eventArgumentCaptor.getValue();
assertEquals(x, viewEvent.getX(), 0d);
assertEquals(y, viewEvent.getY(), 0d);
assertEquals(x, viewEvent.getClientX(), 0d);
assertEquals(y, viewEvent.getClientY(), 0d);
assertTrue(viewEvent.isAltKeyDown());
assertTrue(viewEvent.isMetaKeyDown());
assertTrue(viewEvent.isShiftKeyDown());
assertNotNull(tested.getRegistrationMap().get(ViewEventType.MOUSE_ENTER));
}
Aggregations