edvin
08/24/2017, 11:41 AMAddTab
event. The listener defined inside the TabPane listens for this event and adds tabs on the fly.edvin
08/24/2017, 11:42 AMedvin
08/24/2017, 11:43 AMedvin
08/24/2017, 11:43 AMaayush
08/24/2017, 11:44 AMaayush
08/24/2017, 11:44 AMedvin
08/24/2017, 11:45 AMedvin
08/24/2017, 11:45 AMedvin
08/24/2017, 11:45 AMedvin
08/24/2017, 11:45 AMaayush
08/24/2017, 12:15 PMclass MainView : View() {
override val root = gridpane()
val tv: TabbedView by di("tabView")
val sv: ShortcutView by di("shortcutView")
init {
with(root) {
add(tv.root, 0, 0)
add(sv.root, 1, 0)
isGridLinesVisible=true
columnConstraints.addAll(
newColConstraints(05.0), newColConstraints(15.0), newColConstraints(70.0))
rowConstraints.addAll(newRowConstraints(100.0))
}
}
}
edvin
08/24/2017, 12:31 PMedvin
08/24/2017, 12:31 PMaayush
08/24/2017, 12:33 PMclass MainView : View() {
override val root = gridpane()
val tv: TabbedView by di("tabView")
val sv: ShortcutView by di("shortcutView")
init {
with(root) {
add(tv.root, 0, 0)
add(sv.root, 1, 0)
isGridLinesVisible=true
columnConstraints.addAll(
newColConstraints(05.0), newColConstraints(15.0), newColConstraints(70.0))
rowConstraints.addAll(newRowConstraints(100.0))
}
}
}
class ShortcutView : View() {
override val root = hbox()
init {
with(root) {
listmenu(theme = "black") {
item(text = "Add Tab"){
onDoubleClick {
fire(AddTab(SampleTabView1::class))
}
}
}
}
}
}
class AddTab<T : UIComponent>(val type: KClass<T>) : FXEvent()
class TabbedView : View() {
override val root = hbox {
tabpane {
subscribe<AddTab<*>> {
val uicmp = find(it.type)
if (tabs.map { it.content }.none { it == uicmp.root })
add(uicmp)
}
}
}
}
class SampleTabView1 : Fragment("Sample Tab 1") {
override val root = vbox {
label("Content in Sample Tab 1")
}
}
fun newColConstraints(percentage: Double): ColumnConstraints {
val colCons = ColumnConstraints()
colCons.percentWidth = percentage
colCons.hgrow = Priority.ALWAYS
return colCons
}
fun newRowConstraints(percentage: Double): RowConstraints {
val rowCons = RowConstraints()
rowCons.percentHeight = percentage
rowCons.vgrow = Priority.ALWAYS
return rowCons
}
edvin
08/24/2017, 12:35 PMdi
delegate? Third party dependency injection can't be used with TornadoFX components.edvin
08/24/2017, 12:36 PMaayush
08/24/2017, 12:36 PMedvin
08/24/2017, 12:37 PMinject
delegate, see above.edvin
08/24/2017, 12:37 PMdi
is only for third party dependency injection integration, and can't be used for views and controllers, only for other third party components.edvin
08/24/2017, 12:38 PMedvin
08/24/2017, 12:39 PMonDoubleClick
for your button?edvin
08/24/2017, 12:40 PMedvin
08/24/2017, 12:40 PMimage.png▾
edvin
08/24/2017, 12:41 PMinject
it seems to work at least 🙂edvin
08/24/2017, 12:41 PMaayush
08/24/2017, 12:41 PMedvin
08/24/2017, 12:42 PMaayush
08/24/2017, 12:42 PMedvin
08/24/2017, 12:44 PMaayush
08/24/2017, 12:45 PM