Class: UI::Command
- Inherits:
-
Object
- Object
- UI::Command
Overview
The Command class is used to create toolbar buttons and menu entries for invoking your extension.
Instance Method Summary # collapse
-
#extension ⇒ SketchupExtension?
The #extension method returns the command’s associated extension.
-
#extension=(extension) ⇒ Object
The #extension= method explicitly sets the command’s associated extension.
-
#get_validation_proc ⇒ Proc?
The #get_validation_proc method returns the command’s validation proc.
-
#new(menutext) { ... } ⇒ UI::Command
constructor
The new method is used to create a new command.
-
#large_icon ⇒ String
The large_icon method returns the icon file for the command’s large icon.
-
#large_icon=(path) ⇒ String
The large_icon= method is used to set the icon file for the command’s large icon.
-
#menu_text ⇒ String
The menu_text method returns the menu item name for the command.
-
#menu_text=(menuitem) ⇒ String
The menu_text= method is used to set the menu item name for the command.
-
#proc ⇒ Proc
The #proc method returns the command’s proc that is called when the command is invoked.
-
#set_validation_proc { ... } ⇒ UI::Command
The #set_validation_proc method allows you to change whether the command is enabled, checked, etc.
-
#small_icon ⇒ String
The small_icon method returns the icon file for the command’s small icon.
-
#small_icon=(path) ⇒ String
The small_icon= method is used to set the icon file for the command’s small icon.
-
#status_bar_text ⇒ String
The status_bar_text method returns the description of the command.
-
#status_bar_text=(text) ⇒ String
The status_bar_text= method is used to set the description for the command.
-
#tooltip ⇒ String
The tooltip method returns command item’s tooltip’s header text.
-
#tooltip=(text) ⇒ String
The #tooltip= method is used to define a command item’s tooltip header.
Constructor Details
↑ #new(menutext) { ... } ⇒ UI::Command
The new method is used to create a new command.
Instance Method Details
↑ #extension ⇒ SketchupExtension?
The #extension method returns the command’s associated extension.
↑ #extension=(extension) ⇒ Object
This is an advanced feature that extension developers normally won’t have to deal with. It’s purpose is to address scenarios when SketchUp isn’t able to automatically infer which extension the command belongs to. These scenarios are for example an extension using a library to add its commands or command manager extensions.
The #extension= method explicitly sets the command’s associated extension.
↑ #get_validation_proc ⇒ Proc?
The #get_validation_proc method returns the command’s validation proc.
↑ #large_icon=(path) ⇒ String
The large_icon= method is used to set the icon file for the command’s large icon. large icons should be 32x32 pixel images for best display quality. Along the edge there should be a 4 px empty margin for the icon to match those of native SketchUp commands.
Starting in SketchUp 2016 it is possible to use vector images for better display at varying UI scaling. SVG format for Windows and PDF format for Mac. Since the vector images scale for both small and large icon sizes, you only need to use one.
Starting in SketchUp 2027 it is possible to use SVG on both Windows and Mac.
↑ #menu_text=(menuitem) ⇒ String
The menu_text= method is used to set the menu item name for the command.
↑ #proc ⇒ Proc
The #proc method returns the command’s proc that is called when the command is invoked.
↑ #set_validation_proc { ... } ⇒ UI::Command
Avoid disabling an command as it often isn’t obvious to the user why it is disabled. Prefer keeping the command enabled but show an error message if pressed when it cannot be used.
The #set_validation_proc method allows you to change whether the command is enabled, checked, etc. For instance, the command toggling a dialog window may be displayed as checked while the dialog is open.
↑ #small_icon=(path) ⇒ String
The small_icon= method is used to set the icon file for the command’s small icon. Small icons should be 24x24 pixel images for best display quality.
Starting in SketchUp 2016 it is possible to use vector images for better display at varying UI scaling. SVG format for Windows and PDF format for Mac. Since the vector images scale for both small and large icon sizes, you only need to use one.
Starting in SketchUp 2027 it is possible to use SVG on both Windows and Mac.
↑ #status_bar_text=(text) ⇒ String
The status_bar_text= method is used to set the description for the command. This should typically be a one sentence paragraph with a trailing point.
↑ #tooltip=(text) ⇒ String
The tooltip text should repeat the commands’ title text. For the command description, use #status_bar_text.
The #tooltip= method is used to define a command item’s tooltip header. Tooltips will appear when the command is attached to a tool bar and the user hovers their cursor over the icon.