Views
4 months ago

tornadofx-guide

4. Basic Controls

4. Basic Controls button("Save") { action { doSave() } shortcut("Ctrl+S") } Touch Support JavaFX supports touch out of the box, and TornadoFX makes a few improvements especially for shortpress and longpress durations. It consists of two functions similar to action , which can be configured on any Node : shortpress { println("Activated on short press") } longpress { println("Activated on long press") } Both functions accepts a consume parameter which by default is false . Setting it to true will prevent event bubbling for the press event. The longpress function additionally supports a threshold parameter which is used to determine when a longpress has occurred. It is 700.millis by default. SUMMARY In this chapter we learned about TornadoFX builders and how they work simply by using Kotlin extension functions. We also covered builders for basic controls like Button , TextField and ImageView . In the coming chapters we will learn about builders for tables, layouts, menus, charts, and other controls. As you will see, combining all these builders together creates a powerful way to express complex UI's with very structured and minimal code. There are many other builder controls, and the maintainers of TornadoFX have strived to create a builder for every JavaFX control. If you need something that is not covered here, use Google to see if its included in JavaFX. Chances are if a control is available in JavaFX, there is a builder with the same name in TornadoFX. These are not the only control builders in the TornadoFX API, and this guide does its best to keep up. Always check the TornadoFX GitHub to see the latest builders and functionalities available, and file an issue if you see any missing. We are not done covering builders yet though. In the next section, we will cover more complex controls in the next few sections. 50

4. Basic Controls 51

GUIDE
GUIDE
Guide
Guide
GUIDE
Guide
GUIDE
GUIDE
GUIDE
GUIDE