-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close Notification
onClick
only not onDrag
- Loading branch information
1 parent
2fd1ae8
commit c741f21
Showing
3 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
Azkar/src/main/java/com/bayoumi/util/gui/ClickHandlerAndIgnoreDrag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.bayoumi.util.gui; | ||
|
||
import javafx.event.EventHandler; | ||
import javafx.scene.input.MouseEvent; | ||
|
||
public class ClickHandlerAndIgnoreDrag implements EventHandler<MouseEvent> { | ||
|
||
private final EventHandler<MouseEvent> onClickedEventHandler; | ||
|
||
private boolean dragging = false; | ||
|
||
public ClickHandlerAndIgnoreDrag(EventHandler<MouseEvent> onClickedEventHandler) { | ||
this.onClickedEventHandler = onClickedEventHandler; | ||
} | ||
|
||
@Override | ||
public void handle(MouseEvent event) { | ||
if (event.getEventType() == MouseEvent.MOUSE_PRESSED) { | ||
dragging = false; | ||
} else if (event.getEventType() == MouseEvent.DRAG_DETECTED) { | ||
dragging = true; | ||
} else if (event.getEventType() == MouseEvent.MOUSE_DRAGGED) { | ||
//maybe filter on dragging (== true) | ||
} else if (event.getEventType() == MouseEvent.MOUSE_CLICKED) { | ||
if (!dragging) { | ||
onClickedEventHandler.handle(event); | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters