How to Change the Extension's UI from the Ruby Script?
-
Dear Sketchucationers,
Looking for a quick intro/tutorial into how to manipulate the UI aspect of .rb scripts. For example, how can I change where an extension appears on the menu bar? or how can I change the items that appear in the context-click menu? Some Ruby tips appreciated too!
-
Look through my RB scripts and see how this is done in detail...
for a simple menu item
SUBMENU=UI.menu("Plugins").add_submenu("Haujiet") #Or other menu by name e.g. 'Tools' SUBMENU.add_item("Add..."){Sketchup.active_model.select_tool(Haujiet_Tool.new())} SUBMENU.add_item("Settings..."){Haujiet_Module;;settings()}for a command
CMD1=UI;;Command.new("Tool_name"){Haujiet_Module;;some_module_action()} CMD1.tooltip="How_to_use_tool..." CMD1.status_bar_text="How_to_use_tool..." CMD1.small_icon=File.join(FOLDER_path, 'icon.png') CMD1.large_icon=File.join(FOLDER_path, 'icon.png')and for Toolbar
TOOLBAR=UI;;Toolbar.new("Haujiet...") TOOLBAR.add_item(CMD1) TOOLBAR.restore if TOOLBAR.get_last_state.abs == 1 #TB_VISIBLE/NEVERfor a context menu
UI.add_context_menu_handler{|menu| sub = menu.add_submenu("Haujiet...") sub.add_item(CMD1) # perhaps with tests to see if it should show - e.g. the selection is a group? }See here...
http://ruby.sketchup.com/UI/Command.html
http://ruby.sketchup.com/UI/Toolbar.html
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better đź’—
Register LoginAdvertisement