Hi Matthias,
I'm very new on Ruby...
To refer your example about simple menu adding and try to add sub-menu on it
the code will look like...
app = RBA::Application.instance
$menu_handler = MenuHandler.new
$menu_handler.title = "RBA test"
menu = app.main_window.menu
menu.insert_menu("@toolbar.end", "Func", "Function")
menu.insert_item("@toolbar.Func.end", "rba_test1", $menu_handler)
menu.insert_item("@toolbar.Func.end", "rba_test2", $menu_handler)
and the result only show "rba_test2"
any mistake I make?
Comments
Hi cls,
You clearly followed the example on this page: http://www.klayout.de/0.22/doc/programming/traditional.html.
You can do it with 'MenuHandler' as I talk more about below, but 'MenuHandler' is not necessary. Let's look at maybe the simplest example to get you started.
In the future, perhaps a constructor can be added to the Action class in RBA to take care of the 'a. ...' and 'b. ...' lines all in one fell swoop. But for right now you need at least three lines for each one. Or you could do it by extending the MenuHandler class with a new constructor (Google for 'def initialize').
(Note, in this forum, you can indent each line by at least four spaces to get it to show up as code, as you see above. Google for "Markdown syntax")
Lastly, I would avoid "$" global variables if unnecessary. In rare cases they are truly necessary or at least preferable, though.
David
Hello,
thanks for these value comments, David!
And sure, the constructor can be added. My list of TODO items is growing longer every day ...
Matthias