|
水平有限真看不懂这些
SketchUp Ruby API Reference
Class Index
Method Index
Developers Guide
Examples
Toolbar class
The Toolbar class contains methods to create and manipulate SketchUp toolbars in Ruby.
Parent: Object
Methods: new, add_item, add_seperator, get_last_state, hide, restore, show, visible?
Example Code: toolbartests.rb
Class Methods
new
The new method creates a new Toolbar object.
Syntax
toolbar = UI::Toolbar.new "toolbarname"
Arguments
"toolbarname" - the name for the new toolbar
Return Value
toolbar - the newly created toolbar object
Example
toolbar = UI::Toolbar.new "Test"
Instance Methods
add_item
The add_item method is used to add an item to the toolbar.
Syntax
toolbar = toolbar.add_item command
Arguments
command - a Command object representing the command to add to the toolbar
Return Value
toolbar - the toolbar where the command was just added
Example
toolbar = UI::Toolbar.new "Test"# This toolbar tool simply displays Hello World on the screen when clickedcmd = UI::Command.new($tStrings.GetString("Test")) { helloWorld
}cmd.small_icon = "ToolPencilSmall.png"cmd.large_icon = "ToolPencilLarge.png"cmd.tooltip = $tStrings.GetString("Test Toolbars")cmd.status_bar_text = $tStrings.GetString("Testing the toolbars class")cmd.menu_text = $tStrings.GetString("Test")toolbar = toolbar.add_item cmdtoolbar.showif (toolbar)UI.messagebox toolbarelseUI.messagebox "Failure"end
add_separator
The add_separator method is used to add a line separator to the toolbar.
Syntax
toolbar = toolbar.add_seperator
Return Value
toolbar - the toolbar where the line separator was just added
Example
toolbar = UI::Toolbar.new "Test"# This toolbar tool simply displays Hello World on the screen when clickedcmd = UI::Command.new($tStrings.GetString("Test")) { helloWorld
}cmd.small_icon = "ToolPencilSmall.png"cmd.large_icon = "ToolPencilLarge.png"cmd.tooltip = $tStrings.GetString("Test Toolbars")cmd.status_bar_text = $tStrings.GetString("Testing the toolbars class")cmd.menu_text = $tStrings.GetString("Test")toolbar = toolbar.add_item cmdtoolbar = toolbar.add_separatorcmd2 = UI::Command.new($tStrings.GetString("Test Two")) { helloWorld
} cmd2.small_icon = "ToolPencilSmall.png"cmd2.large_icon = "ToolPencilLarge.png"cmd2.tooltip = $tStrings.GetString("Test Toolbars")cmd2.status_bar_text = $tStrings.GetString("Testing the toolbars class")cmd2.menu_text = $tStrings.GetString("Test")toolbar = toolbar.add_item cmd2toolbar.showif (toolbar)UI.messagebox toolbarelseUI.messagebox "Failure"end
get_last_state
The get_last_state method is used to determine if the toolbar is hidden or visible in the user interface.
Syntax
state = toolbar.get_last_state
Return Value
state - the last state of the toolbar (see comments)
Comments
Valid states are 1 for visible, 0 for hidden, -1 for never shown.
Example
toolbar = UI::Toolbar.new "Test"# This toolbar tool simply displays Hello World on the screen when clickedcmd = UI::Command.new($tStrings.GetString("Test")) { helloWorld
} cmd.small_icon = "ToolPencilSmall.png"cmd.large_icon = "ToolPencilLarge.png"cmd.tooltip = $tStrings.GetString("Test Toolbars")cmd.status_bar_text = $tStrings.GetString("Testing the toolbars class")cmd.menu_text = $tStrings.GetString("Test")toolbar = toolbar.add_item cmdtoolbar.showstate = toolbar.get_last_stateif (state)UI.messagebox stateelseUI.messagebox "Failure"end
hide
The hide method is used to hide the toolbar on the user interface.
Syntax
toolbar.hide
Example
toolbar = UI::Toolbar.new "Test"# This toolbar tool simply displays Hello World on the screen when clickedcmd = UI::Command.new($tStrings.GetString("Test")) { helloWorld
} cmd.small_icon = "ToolPencilSmall.png"cmd.large_icon = "ToolPencilLarge.png"cmd.tooltip = $tStrings.GetString("Test Toolbars")cmd.status_bar_text = $tStrings.GetString("Testing the toolbars class")cmd.menu_text = $tStrings.GetString("Test")toolbar = toolbar.add_item cmdtoolbar.showUI.messagebox "Toolbar Showing"toolbar.hideUI.messagebox "Toolbar Hidden"
restore
The restore method is used to reposition the toolbar to its previous location and show if not hidden.
Syntax
toolbar.restore
Example
toolbar = UI::Toolbar.new "Test"# This toolbar tool simply displays Hello World on the screen when clickedcmd = UI::Command.new($tStrings.GetString("Test")) { helloWorld
} cmd.small_icon = "ToolPencilSmall.png"cmd.large_icon = "ToolPencilLarge.png"cmd.tooltip = $tStrings.GetString("Test Toolbars")cmd.status_bar_text = $tStrings.GetString("Testing the toolbars class")cmd.menu_text = $tStrings.GetString("Test")toolbar = toolbar.add_item cmdtoolbar.restore
show
The show method is used to display the toolbar in the user interface.
Syntax
toolbar.show
Example
toolbar = UI::Toolbar.new "Test"# This toolbar tool simply displays Hello World on the screen when clickedcmd = UI::Command.new($tStrings.GetString("Test")) { helloWorld
} cmd.small_icon = "ToolPencilSmall.png"cmd.large_icon = "ToolPencilLarge.png"cmd.tooltip = $tStrings.GetString("Test Toolbars")cmd.status_bar_text = $tStrings.GetString("Testing the toolbars class")cmd.menu_text = $tStrings.GetString("Test")toolbar = toolbar.add_item cmdtoolbar.show
visible?
The visible? method is used to determine if the toolbar is currently visible in the user interface.
Syntax
status = toolbar.visible?
Return Value
status - true if visible, false if not visible
Example
toolbar = UI::Toolbar.new "Test"# This toolbar tool simply displays Hello World on the screen when clickedcmd = UI::Command.new($tStrings.GetString("Test")) { helloWorld
} cmd.small_icon = "ToolPencilSmall.png"cmd.large_icon = "ToolPencilLarge.png"cmd.tooltip = $tStrings.GetString("Test Toolbars")cmd.status_bar_text = $tStrings.GetString("Testing the toolbars class")cmd.menu_text = $tStrings.GetString("Test")toolbar = toolbar.add_item cmdtoolbar.showstatus = toolbar.visible?if (status)UI.messagebox statuselseUI.messagebox statusend |
|