Java Code Examples for javafx.scene.Node#removeEventHandler()
The following examples show how to use
javafx.scene.Node#removeEventHandler() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Setting.java From PreferencesFX with Apache License 2.0 | 6 votes |
/** * Unmarks a setting. * Is used for the search, which marks and unmarks items depending on the match as a form of * visual feedback. */ public void unmark() { if (!hasDescription()) { throw new UnsupportedOperationException( "Only Fields can be unmarked, since they have a description." ); } // check if it's marked before removing the style class if (marked) { SimpleControl renderer = (SimpleControl) ((Field) getElement()).getRenderer(); Node markNode = renderer.getFieldLabel(); markNode.getStyleClass().remove(MARKED_STYLE_CLASS); markNode.removeEventHandler(MouseEvent.MOUSE_EXITED, unmarker); marked = !marked; } }
Example 2
Source File: JFXTooltip.java From JFoenix with Apache License 2.0 | 6 votes |
private void install(Node node, JFXTooltip tooltip) { if (node == null) { return; } if (tooltip == null) { uninstall(node); return; } node.removeEventHandler(MouseEvent.MOUSE_MOVED, weakMoveHandler); node.removeEventHandler(MouseEvent.MOUSE_EXITED, weakExitHandler); node.removeEventHandler(MouseEvent.MOUSE_PRESSED, weakPressedHandler); node.addEventHandler(MouseEvent.MOUSE_MOVED, weakMoveHandler); node.addEventHandler(MouseEvent.MOUSE_EXITED, weakExitHandler); node.addEventHandler(MouseEvent.MOUSE_PRESSED, weakPressedHandler); node.getProperties().put(TOOLTIP_PROP, tooltip); }
Example 3
Source File: ConnectorDragManager.java From graph-editor with Eclipse Public License 1.0 | 6 votes |
/** * Removes any previously existing mouse event handlers from the connector's root JavaFX node that were added by * this class. * * @param connector the {@link GConnector} whose old handlers should be removed */ private void removeOldMouseHandlers(final GConnector connector) { final Node root = skinLookup.lookupConnector(connector).getRoot(); if (mouseEnteredHandlers.get(connector) != null) { root.removeEventHandler(MouseEvent.MOUSE_ENTERED, mouseEnteredHandlers.get(connector)); } if (mouseExitedHandlers.get(connector) != null) { root.removeEventHandler(MouseEvent.MOUSE_EXITED, mouseExitedHandlers.get(connector)); } if (mouseReleasedHandlers.get(connector) != null) { root.removeEventHandler(MouseEvent.MOUSE_RELEASED, mouseReleasedHandlers.get(connector)); } if (mouseMovedHandlers.get(connector) != null) { root.removeEventHandler(MouseEvent.MOUSE_MOVED, mouseMovedHandlers.get(connector)); } }
Example 4
Source File: ConnectorDragManager.java From graph-editor with Eclipse Public License 1.0 | 6 votes |
/** * Removes any previously existing mouse-drag event handlers from the connector's root JavaFX node that were added * by this class. * * @param connector the {@link GConnector} whose old handlers should be removed */ private void removeOldMouseDragHandlers(final GConnector connector) { final Node root = skinLookup.lookupConnector(connector).getRoot(); if (dragDetectedHandlers.get(connector) != null) { root.removeEventHandler(MouseEvent.DRAG_DETECTED, dragDetectedHandlers.get(connector)); } if (mouseDraggedHandlers.get(connector) != null) { root.removeEventHandler(MouseEvent.MOUSE_DRAGGED, mouseDraggedHandlers.get(connector)); } if (mouseDragEnteredHandlers.get(connector) != null) { root.removeEventHandler(MouseDragEvent.MOUSE_DRAG_ENTERED, mouseDragEnteredHandlers.get(connector)); } if (mouseDragExitedHandlers.get(connector) != null) { root.removeEventHandler(MouseDragEvent.MOUSE_DRAG_EXITED, mouseDragExitedHandlers.get(connector)); } if (mouseDragReleasedHandlers.get(connector) != null) { root.removeEventHandler(MouseDragEvent.MOUSE_DRAG_RELEASED, mouseDragReleasedHandlers.get(connector)); } }
Example 5
Source File: ChartPlugin.java From chart-fx with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private <T extends InputEvent> void removeEventHandlers(final Node node) { if (node == null) { return; } for (final Pair<EventType<? extends InputEvent>, EventHandler<? extends InputEvent>> pair : mouseEventHandlers) { final EventType<T> type = (EventType<T>) pair.getKey(); final EventHandler<T> handler = (EventHandler<T>) pair.getValue(); node.removeEventHandler(type, handler); if (node.getScene() != null) { node.getScene().removeEventFilter(type, handler); } } }
Example 6
Source File: PaintClickOrDrag.java From paintera with GNU General Public License v2.0 | 5 votes |
@Override public void removeFrom(final Node node) { node.removeEventHandler(MouseEvent.MOUSE_PRESSED, onPress); node.removeEventHandler(MouseEvent.MOUSE_DRAGGED, onDragOrMove); node.removeEventHandler(MouseEvent.MOUSE_MOVED, onDragOrMove); node.removeEventHandler(MouseEvent.MOUSE_RELEASED, onRelease); }
Example 7
Source File: JFXTooltip.java From JFoenix with Apache License 2.0 | 5 votes |
private void uninstall(Node node) { if (node == null) { return; } node.removeEventHandler(MouseEvent.MOUSE_MOVED, weakMoveHandler); node.removeEventHandler(MouseEvent.MOUSE_EXITED, weakExitHandler); node.removeEventHandler(MouseEvent.MOUSE_PRESSED, weakPressedHandler); Object tooltip = node.getProperties().get(TOOLTIP_PROP); if (tooltip != null) { node.getProperties().remove(TOOLTIP_PROP); if (tooltip.equals(currentTooltip) || tooltip.equals(nextTooltip)) { weakPressedHandler.handle(null); } } }
Example 8
Source File: EventStreams.java From ReactFX with BSD 2-Clause "Simplified" License | 5 votes |
public static <T extends Event> EventStream<T> eventsOf( Node node, EventType<T> eventType) { return new EventStreamBase<T>() { @Override protected Subscription observeInputs() { EventHandler<T> handler = this::emit; node.addEventHandler(eventType, handler); return () -> node.removeEventHandler(eventType, handler); } }; }
Example 9
Source File: ReactfxUtil.java From pmd-designer with BSD 2-Clause "Simplified" License | 4 votes |
public static <T extends Event> Subscription addEventHandler(Node node, EventType<T> type, EventHandler<T> handler) { node.addEventHandler(type, handler); return () -> node.removeEventHandler(type, handler); }
Example 10
Source File: CardListView.java From metastone with GNU General Public License v2.0 | 4 votes |
private void clearChildren() { for (Node child : getChildren()) { child.removeEventHandler(MouseEvent.MOUSE_CLICKED, this); } getChildren().clear(); }
Example 11
Source File: DeckListView.java From metastone with GNU General Public License v2.0 | 4 votes |
private void clearChildren() { for (Node child : getChildren()) { child.removeEventHandler(MouseEvent.MOUSE_CLICKED, this); } getChildren().clear(); }
Example 12
Source File: SelectionCreator.java From graph-editor with Eclipse Public License 1.0 | 4 votes |
/** * Adds a click selection mechanism for nodes. */ private void addClickSelectionForNodes() { for (final GNode node : model.getNodes()) { final Region nodeRegion = skinLookup.lookupNode(node).getRoot(); final EventHandler<MouseEvent> oldNodePressedHandler = nodePressedHandlers.get(node); final EventHandler<MouseEvent> oldNodeReleasedHandler = nodeReleasedHandlers.get(node); if (oldNodePressedHandler != null) { nodeRegion.removeEventHandler(MouseEvent.MOUSE_PRESSED, oldNodePressedHandler); } if (oldNodeReleasedHandler != null) { nodeRegion.removeEventHandler(MouseEvent.MOUSE_RELEASED, oldNodeReleasedHandler); } final EventHandler<MouseEvent> newNodePressedHandler = event -> handleNodePressed(event, node); final EventHandler<MouseEvent> newNodeReleasedHandler = event -> handleNodeReleased(event, node); nodeRegion.addEventHandler(MouseEvent.MOUSE_PRESSED, newNodePressedHandler); nodeRegion.addEventHandler(MouseEvent.MOUSE_RELEASED, newNodeReleasedHandler); nodePressedHandlers.put(node, newNodePressedHandler); nodeReleasedHandlers.put(node, newNodeReleasedHandler); for (final GConnector connector : node.getConnectors()) { final Node connectorRoot = skinLookup.lookupConnector(connector).getRoot(); final EventHandler<MouseEvent> oldConnectorPressedHandler = connectorPressedHandlers.get(connector); if (oldConnectorPressedHandler != null) { connectorRoot.removeEventHandler(MouseEvent.MOUSE_PRESSED, oldConnectorPressedHandler); } final EventHandler<MouseEvent> newConnectorPressedHandler = event -> handleConnectorPressed(event); connectorRoot.addEventHandler(MouseEvent.MOUSE_PRESSED, newConnectorPressedHandler); connectorPressedHandlers.put(connector, newConnectorPressedHandler); } } }