0

I have a ComboBox of objects with GridPane set as Graphic for displaying combobox list. GridPane has 3 columns for image, item's label and a StackPane. I want to click on StackPane and get object that corresponds to this row, but through .getParent().getChildrenUnmodifiable().get(0) I can only get label. If I use .getParent().getParent() that will give me a cell of clicked row. If I'm just changing selection of combobox, I can retrieve object normaly. But how to get object, which stackpane was clicked? enter image description here

4

1 に答える 1

0

カスタムの StackPane にマウス クリック リスナーを問題なく追加したと仮定するとListCell(このマウス クリック イベントはコンボボックス行によって消費され、さらに stackPane に伝播されない可能性があるため)、getItem()このマウス リスナーを呼び出して、関連するオブジェクトにアクセスできます。この細胞。

すべてのレイアウト ノード (GridPane、Stackpane など) は、セルのアイテムのレンダラーです。したがって、このレイアウト グラフをトラバースして項目 (オブジェクト) にアクセスすることはできません。

于 2015-05-07T11:03:40.143 に答える