Skip to content

Commit

Permalink
Update mouse event handling in EnhancedPasswordField
Browse files Browse the repository at this point in the history
Replaced the setOnMouseClicked event handler with a MOUSE_PRESSED event handler in the EnhancedPasswordField class. This will prevent unwanted event propagation when the rightWrapper node is clicked. Added event.consume() to ensure the event is fully processed.
  • Loading branch information
leewyatt committed Jun 10, 2024
1 parent c6d9b55 commit 9285159
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import javafx.scene.Node;
import javafx.scene.control.PasswordField;
import javafx.scene.control.Skin;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;

Expand Down Expand Up @@ -73,9 +74,10 @@ public EnhancedPasswordField() {

StackPane rightWrapper = new StackPane(rightIcon);
rightWrapper.getStyleClass().add("right-icon-wrapper");
rightWrapper.setOnMouseClicked(event -> {
rightWrapper.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> {
if (UIUtil.clickOnNode(event)) {
setShowPassword(!isShowPassword());
event.consume();
}
});
setRight(rightWrapper);
Expand Down

0 comments on commit 9285159

Please sign in to comment.