Using the @FXML annotations in Kotlin to get at FXML

Hi.

I think that using Delegates.notNull() will not work without doing some additional “magic”.

Lets says that we have this declaration

FXML var tabPane: TabPane by Delegates.notNull()

At Kotlin Bytecode we can see that tabPane is converted into field_name$delegate and it's type is migrated to ReadWriteProperty. To set TabPane it is required to invoke setTabPane method which FXMLLoader will not do.

I think that in order to make FXML annotaton works we(community) have to create custom FXMLLoader and maybe some custom Delegator (witch allow make FXML fields as values not variables).

In my opinion someting like this should be a nice way to bind FXML components within controller class:

val tabPane: TabPane by bindFXML()

Where bindFXML() should be initialized by custom FXMLLoader

I will try do some proof-of-concept in few next days.