Class: UI::Toolbar

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/sketchup-api-stubs/stubs/UI/Toolbar.rb

Overview

The Toolbar class contains methods to create and manipulate SketchUp toolbars in Ruby. Toolbars are collections of buttons that you can use to activate custom Tools or ruby scripts.

Also see the Command object for details on creating “commands” which can be called from your toolbars.

Examples:

toolbar = UI::Toolbar.new "Test"
# This toolbar icon simply displays Hello World on the screen
cmd = UI::Command.new("Test") {
  UI.messagebox "Hello World"
}
cmd.small_icon = "ToolPencilSmall.png"
cmd.large_icon = "ToolPencilLarge.png"
cmd.tooltip = "Test Toolbars"
cmd.status_bar_text = "Testing the toolbars class"
cmd.menu_text = "Test"
toolbar = toolbar.add_item cmd
toolbar.show

Version:

  • SketchUp 6.0

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(toolbarname) ⇒ UI::Toolbar

The new method creates a new Toolbar object.

Examples:

toolbar = UI::Toolbar.new "Test"

Parameters:

  • toolbarname (String)

    The name for the new toolbar.

Returns:

Version:

  • SketchUp 6.0



45
46
# File 'lib/sketchup-api-stubs/stubs/UI/Toolbar.rb', line 45

def self.new(toolbarname)
end

Instance Method Details

#add_item(command) ⇒ UI::Toolbar

The add_item method is used to add an item to the toolbar.

Examples:

toolbar = toolbar.add_item command

Parameters:

  • command (UI::Command)

    A Command object representing the command to add to the toolbar.

Returns:

  • (UI::Toolbar)

    the toolbar where the command was just added

Version:

  • SketchUp 6.0



62
63
# File 'lib/sketchup-api-stubs/stubs/UI/Toolbar.rb', line 62

def add_item(command)
end

#add_separator(arg) ⇒ UI::Toolbar

The add_separator method is used to add a line separator to the toolbar.

Examples:

toolbar = toolbar.add_separator

Returns:

  • (UI::Toolbar)

    the toolbar where the line separator was just added

Version:

  • SketchUp 6.0



73
74
# File 'lib/sketchup-api-stubs/stubs/UI/Toolbar.rb', line 73

def add_separator(arg)
end

#countInteger

The #count method is inherited from the Enumerable mix-in module.

Examples:

number = toolbar.count

Returns:

  • (Integer)

Version:

  • SketchUp 2014



84
85
# File 'lib/sketchup-api-stubs/stubs/UI/Toolbar.rb', line 84

def count
end

#each {|key, value| ... } ⇒ nil

The each method is used to iterate through all of the commands attached to a toolbar.

Examples:

toolbar = UI::Toolbar.new "Test"
# This command displays Hello World on the screen when clicked
cmd = UI::Command.new("Test") { UI.messagebox("Hello World") }
toolbar.add_item cmd
toolbar = toolbar.add_separator
cmd = UI::Command.new("Test 2") { UI.messagebox("Hello World 2") }
toolbar.add_item cmd
toolbar.show
toolbar.each { | item |
  puts item
}

Yields:

  • (key, value)

    Variables that will hold each key and value as they are found.

Returns:

  • (nil)

Version:

  • SketchUp 8.0 M1



109
110
# File 'lib/sketchup-api-stubs/stubs/UI/Toolbar.rb', line 109

def each
end

#get_last_stateBoolean

The get_last_state method is used to determine if the toolbar was hidden or visible in the previous session of SketchUp.

Valid states are 1 for visible, 0 for hidden, -1 for before never shown.

Examples:

state = toolbar.get_last_state

Returns:

  • (Boolean)

    the last state of the toolbar (see comments)

Version:

  • SketchUp 6.0



123
124
# File 'lib/sketchup-api-stubs/stubs/UI/Toolbar.rb', line 123

def get_last_state
end

#hidenil

The hide method is used to hide the toolbar on the user interface.

Examples:

toolbar = UI::Toolbar.new "Test"
# This toolbar icon simply displays Hello World on the screen
cmd = UI::Command.new("Test") {
  UI.messagebox "Hello World"
}
cmd.small_icon = "ToolPencilSmall.png"
cmd.large_icon = "ToolPencilLarge.png"
cmd.tooltip = "Test Toolbars"
cmd.status_bar_text = "Testing the toolbars class"
cmd.menu_text = "Test"
toolbar = toolbar.add_item cmd
toolbar.show
UI.messagebox "Toolbar Showing"
toolbar.hide
UI.messagebox "Toolbar Hidden"

Returns:

  • (nil)

Version:

  • SketchUp 6.0



148
149
# File 'lib/sketchup-api-stubs/stubs/UI/Toolbar.rb', line 148

def hide
end

#lengthInteger

The #length method returns the number of items in the toolbar.

Examples:

number = toolbar.length

Returns:

  • (Integer)

See Also:

Version:

  • SketchUp 2014



161
162
# File 'lib/sketchup-api-stubs/stubs/UI/Toolbar.rb', line 161

def length
end

#nameString

The name method returns the name of the toolbar.

Examples:

toolbar = UI::Toolbar.new "Test"
# This command displays Hello World on the screen when clicked
cmd = UI::Command.new("Test") { UI.messagebox("Hello World") }
toolbar.add_item cmd
toolbar = toolbar.add_separator
cmd = UI::Command.new("Test 2") { UI.messagebox("Hello World 2") }
puts toolbar.name
toolbar.show

Returns:

  • (String)

    the name of the toolbar.

Version:

  • SketchUp 8.0 M1



179
180
# File 'lib/sketchup-api-stubs/stubs/UI/Toolbar.rb', line 179

def name
end

#restorenil

The restore method is used to reposition the toolbar to its previous location and show if not hidden.

Examples:

toolbar.restore

Returns:

  • (nil)

Version:

  • SketchUp 6.0



191
192
# File 'lib/sketchup-api-stubs/stubs/UI/Toolbar.rb', line 191

def restore
end

#shownil

The show method is used to display the toolbar in the user interface.

Examples:

toolbar = UI::Toolbar.new "Test"
# This toolbar icon simply displays Hello World on the screen
cmd = UI::Command.new("Test") {
  UI.messagebox "Hello World"
}
cmd.small_icon = "ToolPencilSmall.png"
cmd.large_icon = "ToolPencilLarge.png"
cmd.tooltip = "Test Toolbars"
cmd.status_bar_text = "Testing the toolbars class"
cmd.menu_text = "Test"
toolbar = toolbar.add_item cmd
toolbar.show

Returns:

  • (nil)

Version:

  • SketchUp 6.0



213
214
# File 'lib/sketchup-api-stubs/stubs/UI/Toolbar.rb', line 213

def show
end

#sizeInteger

The #size method is an alias of #length.

Examples:

number = toolbar.size

Returns:

  • (Integer)

See Also:

Version:

  • SketchUp 2014



226
227
# File 'lib/sketchup-api-stubs/stubs/UI/Toolbar.rb', line 226

def size
end

#visible?Boolean

The visible? method is used to find out if a toolbar is currently visible.

Examples:

visible = toolbar.visible?

Returns:

  • (Boolean)

Version:

  • SketchUp 6.0



237
238
# File 'lib/sketchup-api-stubs/stubs/UI/Toolbar.rb', line 237

def visible?
end