🏢 PlaceMaker | 25% off for February including new Google Earth data imports!
Learn more
Programing menu icons
-
Can anyone point me to very simple examples of menu icons, and tell me what to look for. The following is the code used for my menus, is this where I begin to add code to set up the use of icons?
unless file_loaded? File;;basename(__FILE__) add_separator_to_menu("File") UI.menu("File").add_item("Select Component") {hdt_sel_comp} file_loaded File;;basename(__FILE__) end
-
Hi,
If you mean a toolbar, here is a typical code block:
arcs_tb = UI;;Toolbar.new("Arcs") #declare the toolbar object cmd = UI;;Command.new(("Arc-Circle; 3 Points")) { Arc3pts.tool } #create a new command object 'cmd' that launches the tool within the {} cmd.small_icon = "3parc2.png" #set this new command a small icon image (users sets this in the preferences dialog) cmd.large_icon = "3parc.png" #set this new command a large icon image (users sets this in the preferences dialog) cmd.tooltip = "Draw an arc or circle with 3 points" #create a tooltip when hovering the icon arcs_tb.add_item(cmd) #add the command 'cmd' to the toolbar object
You can put the toolbar code (for instance) after your menu settings:
if (not file_loaded?("myScript.rb"))
menu = UI.menu("Plugins") my_menu=menu.add_submenu("my submenu label") my_menu.add_item("Here we go !") { cmd_to_launch }
...
...
arcs_tb = UI::Toolbar.new("Arcs") #declare the toolbar object
cmd = UI::Command.new(("Arc-Circle: 3 Points")) { Arc3pts.tool } #create a new command object 'cmd' that launches the tool within the {}
...
...
file_loaded?("myScript.rb") -
Didier, Thanks, This will speed up access to one of my tools.
Addenda: Wow, that was too easy to do.
Advertisement