All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.dankito.utils.javafx.ui.extensions.PickResultExtensions.kt Maven / Gradle / Ivy

There is a newer version: 1.0.9
Show newest version
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