09.04.2018 Views

tornadofx-guide

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

7. Layouts and Menus<br />

Figure 7.14<br />

You can also optionally provide keyboard shortcuts, graphics, as well as an action function<br />

parameter for each item() to specify the action when it is selected (Figure 7.14).<br />

menubar {<br />

menu("File") {<br />

menu("Connect") {<br />

item("Facebook", graphic = fbIcon).action { println("Connecting Facebook!"<br />

) }<br />

item("Twitter", graphic = twIcon).action { println("Connecting Twitter!")<br />

}<br />

}<br />

item("Save","Shortcut+S").action {<br />

println("Saving!")<br />

}<br />

menu("Quit","Shortcut+Q").action {<br />

println("Quitting!")<br />

}<br />

}<br />

menu("Edit") {<br />

item("Copy","Shortcut+C").action {<br />

println("Copying!")<br />

}<br />

item("Paste","Shortcut+V").action {<br />

println("Pasting!")<br />

}<br />

}<br />

}<br />

Figure 7.14<br />

106

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!