Views
8 months ago

tornadofx-guide

7. Layouts and Menus

7. Layouts and Menus Figure 7.14 You can also optionally provide keyboard shortcuts, graphics, as well as an action function parameter for each item() to specify the action when it is selected (Figure 7.14). menubar { menu("File") { menu("Connect") { item("Facebook", graphic = fbIcon).action { println("Connecting Facebook!" ) } item("Twitter", graphic = twIcon).action { println("Connecting Twitter!") } } item("Save","Shortcut+S").action { println("Saving!") } menu("Quit","Shortcut+Q").action { println("Quitting!") } } menu("Edit") { item("Copy","Shortcut+C").action { println("Copying!") } item("Paste","Shortcut+V").action { println("Pasting!") } } } Figure 7.14 106

7. Layouts and Menus Separators You can declare a separator() between two items in a Menu to create a divider line. This is helpful to group commands in a Menu and distinctly separate them (Figure 7.15). menu("File") { menu("Connect") { item("Facebook") item("Twitter") } separator() item("Save","Shortcut+S") { println("Saving!") } item("Quit","Shortcut+Q") { println("Quitting!") } } Figure 7.15 107

GUIDE
GUIDE
GUIDE
Guide
Guide
GUIDE
GUIDE
GUIDE
Guide
GUIDE
Guide
GUIDE
Guide
GUIDE
GUIDE