The OpenD Programming Language

MainWindow.setMenuAndToolbarFromAnnotatedCode

Adds a menu and toolbar from annotated functions. It uses the top-level annotations from this module, so it is better to put the commands in a separate struct instad of in your window subclass, to avoid potential conflicts with method names (if you do hit one though, you can use @(.icon(...)) instead of plain @icon(...) to disambiguate, though).

        struct Commands {
                @menu("File") {
			@toolbar("") // adds it to a generic toolbar
                        void New() {}
                        void Open() {}
                        void Save() {}
                        @separator
                        void Exit() @accelerator("Alt+F4") @hotkey('x') {
                                window.close();
                        }
                }

                @menu("Edit") {
			@icon(GenericIcons.Undo)
                        void Undo() {
                                undo();
                        }
                        @separator
                        void Cut() {}
                        void Copy() {}
                        void Paste() {}
                }

                @menu("Help") {
                        void About() {}
                }
        }

        Commands commands;

        window.setMenuAndToolbarFromAnnotatedCode(commands);

Note that you can call this function multiple times and it will add the items in order to the given items.

  1. void setMenuAndToolbarFromAnnotatedCode(T t)
  2. void setMenuAndToolbarFromAnnotatedCode(T t)
    class MainWindow
    void
    setMenuAndToolbarFromAnnotatedCode
    (
    T
    )
    (
    T t
    )
    if (
    is(T == class) ||
    is(T == interface)
    )

Meta