ComboBox SAME项选择动作侦听器 [英] ComboBox SAME item selected action listener

查看:167
本文介绍了ComboBox SAME项选择动作侦听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果选择了DIFFERENT值,组合框将触发事件。我想也能够听到选择的SAME项目(也就是说,valueProperty没有改变)。似乎没有办法做到这一点。

A combo box will fire an event if a DIFFERENT value is selected. I want to be also be able to listen to the SAME item being selected (that is, valueProperty has no change). There seems to be no way to do this.

我试图扩展ComboBox,并找到一种方式来监听小弹出菜单被关闭,但我甚至不有权访问!我可以做什么?

I tried extending the ComboBox and finding a way to listen for the little popup menu being closed, but I don't even have access to that! What can I do?

这是我的尝试:

class ResponsiveComboBox<E> extends ComboBox<E> {

    public ResponsiveComboBox() {
        super();
        assert getContextMenu() != null; //Asssertion failed!
        this.getContextMenu().setOnHiding((WindowEvent event) -> {
            fireEvent(new ActionEvent());
        });
    }

}


推荐答案

comboBox.showingProperty().addListener((obs, wasShowing, isShowing) -> {
    if (! isShowing) {
        System.out.println("Combo box popup hidden");
    }
});

此事件处理常式可能会在更改值之前触发。

This event handler might be triggered before the value is changed.

这篇关于ComboBox SAME项选择动作侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆