浏览代码

Little refactor and bug fix

Signed-off-by: PAlex404 <alessandro.parisi406@gmail.com>
PAlex404 4 年之前
父节点
当前提交
2ac75f81f9

+ 2 - 1
materialfx/src/main/java/io/github/palexdev/materialfx/controls/MFXButton.java

@@ -14,6 +14,7 @@ import javafx.geometry.Pos;
 import javafx.scene.Node;
 import javafx.scene.control.Button;
 import javafx.scene.control.Skin;
+import javafx.scene.input.MouseEvent;
 import javafx.scene.paint.Color;
 import javafx.scene.paint.Paint;
 import javafx.util.Duration;
@@ -152,7 +153,7 @@ public class MFXButton extends Button {
 
     protected void setupRippleGenerator() {
         this.getChildren().add(0, rippleGenerator);
-        this.setOnMousePressed(event -> {
+        this.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> {
             rippleGenerator.setGeneratorCenterX(event.getX());
             rippleGenerator.setGeneratorCenterY(event.getY());
             rippleGenerator.createRipple();

+ 1 - 1
materialfx/src/main/java/io/github/palexdev/materialfx/controls/base/AbstractMFXTreeCell.java

@@ -25,7 +25,7 @@ import javafx.scene.layout.HBox;
  * The same concept applies to {@code MFXCheckTreeCell}s.
  * <p>
  * Also, note that to build a cell the height must be fixed for layout reasons, by default it's 27.
- * When the cell is created the {@link #render(T)} method is called.
+ * When the cell is created the {@link #render(Object)} method is called.
  * @param <T> The type of the data within TreeItem.
  */
 public abstract class AbstractMFXTreeCell<T> extends HBox {

+ 3 - 2
materialfx/src/main/java/io/github/palexdev/materialfx/controls/cell/MFXListCell.java

@@ -7,6 +7,7 @@ import javafx.css.*;
 import javafx.geometry.Insets;
 import javafx.scene.Node;
 import javafx.scene.control.ListCell;
+import javafx.scene.input.MouseEvent;
 import javafx.scene.layout.Background;
 import javafx.scene.layout.BackgroundFill;
 import javafx.scene.layout.CornerRadii;
@@ -77,7 +78,7 @@ public class MFXListCell<T> extends ListCell<T> {
         });
 
         hoverProperty().addListener((observable, oldValue, newValue) -> {
-            if (isSelected()) {
+            if (isSelected() || isEmpty()) {
                 return;
             }
 
@@ -214,7 +215,7 @@ public class MFXListCell<T> extends ListCell<T> {
                 getChildren().add(0, rippleGenerator);
             }
 
-            setOnMousePressed(mouseEvent -> {
+            addEventHandler(MouseEvent.MOUSE_PRESSED, mouseEvent -> {
                 rippleGenerator.setGeneratorCenterX(mouseEvent.getX());
                 rippleGenerator.setGeneratorCenterY(mouseEvent.getY());
                 rippleGenerator.createRipple();