我在 TitledPane 中添加了图形(图标),并在其上设置了onMouseCliked
处理程序(打开弹出窗口)。
此事件处理程序使用该事件。 问题是,当我点击图标弹出窗口时, TitledPane 也会被扩展。
我怎么能阻止这个?
public class MyPanel extends BorderPane{
@FXML
TitledPane titledPane;
PopOver popOver;
Text icon;
public MyPanel(){
//FXML injection
popOver = new PopOver(new MyPane());
icon = GlyphsDude.createIcon(FontAwesomeIcon.ANCHOR, "15");
icon.setOnMouseClicked(this::onIconClicked);
titledPane.setGraphic(icon);
}
public void onIconClicked(MouseEvent e){
popOver.show(icon);
e.consume();
}
}
答案 0 :(得分:0)
我找到了解决方案:
我只是在使用MOUSE_CLICKED
事件,而 TitledPane 也在处理MOUSE_PRESSED
/ MOUSE_RELEASED
事件。