lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Jun 20, 2011 at 12:41 AM, Cameron Seebach <pannewb@gmail.com> wrote:
> local menu_template = {
>   {
>     "File",
>     {"New",do_new},
>     {"Open",do_open},
>     "-",
>     {"Exit",do_close},

That's pretty optimal, especially since you wish to override things
like 'active' or 'checked'

I use the following scheme (with LuaJava/Swing)

add_menu_bar(form,{
    "Commands",{
       "Open Machine",open_machine,
       "Close Tab", close_current_machine,
       "Leave Network",leave,
       "Reset Radio",reset,
       "Reconnect to Server",reconnect,
       "Putty to Current",putty_into,
       "Putty to Machine",putty_machine,
       "Execute Remote Command",remote_execute_command
    },
    "Power",{
        "Power voltage",power_voltage,
        "Power status",power_status
    }
})

The idea is that a menu item is a label plus either a function (an
actual item) or a table (which will be a submenu)

Things like accelerators, checked status, etc get encoded in the label string.

steve d.