Skip to content

Custom DSL functions #291

Answered by czyzby
Divelix asked this question in Q&A
Discussion options

You must be logged in to vote

You have to add the window to the lambda signature, so it becomes this, exposing all DSL methods:

fun endWindow(title: String, content: KVisWindow.() -> Unit): VisWindow

We're using a KVisWindow instead of VisWindow for the lambda, as it has access to the DSL.

Also, you're not using an updated version of ktx-vis. There were some notable API changes and performance improvements, so I encourage you to try it out. Updated code that compiles:

import com.kotcrab.vis.ui.widget.VisWindow
import ktx.scene2d.scene2d
import ktx.scene2d.vis.KVisWindow
import ktx.scene2d.vis.visLabel
import ktx.scene2d.vis.visWindow

fun endWindow(title: String, content: KVisWindow.() -> Unit): VisWindow {
  return s…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by czyzby
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #291 on December 11, 2020 14:17.