edvin / tornadofx-controlsfx

ControlsFX Builder extensions and utilities for TornadoFX
Apache License 2.0
71 stars 10 forks source link

[question] "Unresolved reference: checktreeview" #17

Open ysm-coder opened 4 years ago

ysm-coder commented 4 years ago

I think the code example speaks for itself (if not, how do I use CheckTreeView with tornadofx-controlsfx):

import javafx.scene.control.TreeView
import org.controlsfx.control.CheckTreeView
import tornadofx.*

class ExampleView : View("My View") {

    lateinit var tv :TreeView<Any>
    lateinit var ctv :CheckTreeView<Any>

    override val root = borderpane {

        tv = treeview<Any> {  } //Works fine

        ctv = checktreeview<Any> { } //Unresolved reference: checktreeview

    }
}

Update: If I create this fun (which is a modified version of treeview by me) it seems to work:

fun <T> EventTarget.checktreeview(root: CheckBoxTreeItem<T>? = null, op: CheckTreeView<T>.() -> Unit = {}) = CheckTreeView<T>().attachTo(this, op) {
        if (root != null) it.root = root
    }

Does this mean that tornadofx-controlsfx is missing that function?

Update 2: Well Im now sure that atleast with my workaround, you cant use .populate or .cellFormat { text = it.name } (A workaround for this is it to override toString but still missing populate).

edvin commented 4 years ago

The TornadoFX-ControlsFX integration is far from completed, contributions are welcomed :)

ysm-coder commented 4 years ago

I would realy like to contribute but Im lacking the experience. Not only do I have nearly 0 experience with git(hub), but also my only knowledge about javafx is the super usefull tornadofx manual. the function I wrote in the top works, as mentioned it was blindly copied from the tornadofx function (which I found thx to the ide) and changed by blindly adding "check/Check" at the beginning of any "tree/Tree". More an act of desperace which worked for me suprisingly (after I realised that I just had to find a workaround that doesnt use populate). Somebody could copy and past it from my comment somewhere in git to add it I guess.

But if its not completly supported yet, why does CheckTreeView have a checkbox at: https://github.com/edvin/tornadofx-controlsfx ? That was missleading me so I thought I was doing something wrong.

sleonidy commented 4 years ago

@ysm-coder You missing an import of tornadofx.controlsfx.*

So you example should be as following:

import javafx.scene.control.TreeView
import org.controlsfx.control.CheckTreeView
import tornadofx.*
import tornadofx.controlsfx.*

class ExampleView : View("My View") {

    lateinit var tv :TreeView<Any>
    lateinit var ctv :CheckTreeView<Any>

    override val root = borderpane {

        tv = treeview<Any> {  } //Works fine

        ctv = checktreeview<Any> { } //Unresolved reference: checktreeview

    }
}