Views
6 months ago

tornadofx-guide

4. Basic Controls

4. Basic Controls text("Veni\nVidi\nVici") { fill = Color.PURPLE font = Font(20.0) } Figure 4.23 TextFlow If you need to concatenate multiple pieces of text with different formats, the TextFlow control can be helpful (Figure 4.24). textflow { text("Tornado") { fill = Color.PURPLE font = Font(20.0) } text("FX") { fill = Color.ORANGE font = Font(28.0) } } Figure 4.24 You can add any Node to the textflow , including images, using the standard builder functions. Tooltips Inside any Node you can specify a Tooltip via the tooltip() function (Figure 4.25). 48

4. Basic Controls button("Commit") { } tooltip("Writes input to the database") Figure 4.25 Like most other builders, you can provide a closure to customize the Tooltip itself. button("Commit") { tooltip("Writes input to the database") { font = Font.font("Verdana") } } Shortcuts and Key Combinations You can fire actions when certain key combinations are typed. This is done with the shortcut function: shortcut(KeyCombination.valueOf("Ctrl+Y")) { } doSomething() There is also a string version of the shortcut function that does the same but is less verbose: shortcut("Ctrl+Y")) { } doSomething() You can also add shortcuts to button actions directly: 49

Guide
guide
GUIDE
GUIDE
GUIDE
GUIDE
Guide
GUIDE
Guide
guide
GUIDE
GUIDE
GUIDE
Guide
GUIDE TO
Guide
GUIDE