net.dankito.utils.javafx.ui.extensions.PickResultExtensions.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-fx-utils Show documentation
Show all versions of java-fx-utils Show documentation
Some basic JavaFX utils needed in many projects
package net.dankito.utils.javafx.ui.extensions
import javafx.scene.control.ListCell
import javafx.scene.control.ListView
import javafx.scene.control.TableRow
import javafx.scene.control.TableView
import javafx.scene.input.PickResult
fun PickResult?.findClickedListCell(): ListCell? {
var parent = this?.intersectedNode
while(parent != null) {
(parent as? ListCell)?.let { listCell ->
return listCell
}
if(parent is ListView<*>) {
break // we already reached ListView -> we won't find a ListCell
}
parent = parent.parent
}
return null
}
fun PickResult?.findClickedTableRow(): TableRow? {
var parent = this?.intersectedNode
while(parent != null) {
(parent as? TableRow)?.let { tableRow ->
return tableRow
}
if(parent is TableView<*>) {
break // we already reached TableView -> we won't find a TableCell
}
parent = parent.parent
}
return null
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy