Class: UI::Notification

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

Overview

UI::Notification objects allows you to show native notifications in the desktop, they are positioned in the top right of your screen, they can be customized to have a message, icon and accept and/or dismiss buttons with callback blocks.

Version:

  • SketchUp 2017

Instance Method Summary collapse

Constructor Details

#initialize(sketchup_extension, message, icon_name, icon_tooltip) ⇒ UI::Notification

The new method is used to create a new UI::Notification.

In order to insert line breaks into the message you need to use \r\n.

Examples:

notification = UI::Notification.new(sketchup_extension, "Hello world", "/path/to/icon", "icon Tooltip")
notification.show

Parameters:

  • sketchup_extension (SketchupExtension)

    Required sketchup_extension to identify the sender.

  • message (String)

    Optionally assign the message.

  • icon_name (String)

    Optionally set a path to an image.

  • icon_tooltip (String)

    Optionally set an image tooltip.

Version:

  • SketchUp 2017



100
101
# File 'lib/sketchup-api-stubs/stubs/UI/Notification.rb', line 100

def initialize(sketchup_extension, message, icon_name, icon_tooltip)
end

Instance Method Details

#icon_nameString

Gets the icon name, this is the path that will be used to get the icon from the file system path.

Examples:

notification = UI::Notification.new(sketchup_extension, "Hello world", "/path/to/icon", "icon Tooltip")
puts "Icon Name: #{notification.icon_name}"
notification.show

Returns:

Version:

  • SketchUp 2017



25
26
# File 'lib/sketchup-api-stubs/stubs/UI/Notification.rb', line 25

def icon_name
end

#icon_name=(icon_name) ⇒ Boolean

Sets the icon path, this icon will be loaded from the path give, the path has to be a local filesystem path.

Examples:

notification = UI::Notification.new(sketchup_extension, "Hello world")
notification.icon_name = "/path/to/icon"
notification.show

Parameters:

  • icon_name (String)

    String providing the icon filesystem path.

Returns:

  • (Boolean)

Version:

  • SketchUp 2017



42
43
# File 'lib/sketchup-api-stubs/stubs/UI/Notification.rb', line 42

def icon_name=(icon_name)
end

#icon_tooltipString

Gets the icon Tooltip, this is the string that appear when the mouse is over the icon.

Examples:

notification = UI::Notification.new(sketchup_extension, "Hello world", "/path/to/icon", "icon Tooltip")
puts "Tooltip: #{notification.icon_tooltip}"
notification.show

Returns:

Version:

  • SketchUp 2017



56
57
# File 'lib/sketchup-api-stubs/stubs/UI/Notification.rb', line 56

def icon_tooltip
end

#icon_tooltip=(icon_tooltip) ⇒ Boolean

Sets the icon Tooltip, this string will appear when the mouse is over the icon.

Examples:

notification = UI::Notification.new(sketchup_extension, "Hello world")
notification.icon_tooltip = "icon Tooltip"
notification.show

Parameters:

  • icon_tooltip (String)

    String providing the new icon Tooltip.

Returns:

  • (Boolean)

Version:

  • SketchUp 2017



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

def icon_tooltip=(icon_tooltip)
end

#messageString

Gets the message as string.

Examples:

notification = UI::Notification.new(sketchup_extension)
puts "This is the current message: #{notification.message}"
notification.show

Returns:

Version:

  • SketchUp 2017



113
114
# File 'lib/sketchup-api-stubs/stubs/UI/Notification.rb', line 113

def message
end

#message=(message) ⇒ Boolean

Sets a new message, notifications are meant for quick & brief messages, remember that they are dismissed automatically.

Examples:

notification = UI::Notification.new(sketchup_extension)
notification.message = "Hello world"
notification.show

Parameters:

  • message (String)

    String providing the new message.

Returns:

  • (Boolean)

Version:

  • SketchUp 2017



130
131
# File 'lib/sketchup-api-stubs/stubs/UI/Notification.rb', line 130

def message=(message)
end

#on_accept(title, block) ⇒ Boolean

Shows a button in the notification with the given title and callback block, both arguments are required.

Examples:

notification = UI::Notification.new(sketchup_extension, "Hello world")
notification.on_accept("Accept")  do |notification, title|
   puts "The user pressed [#{title}] with message #{notification.message}"
end
notification.show

Parameters:

  • title (String)

    Sets the title of the button.

  • block (Block)

    Sets the action callback, this will be called when the user clicks on the dismiss button.

Returns:

  • (Boolean)

Raises:

  • (RuntimeError)

    When calling on_accept when the notification has already been shown.

Version:

  • SketchUp 2017



156
157
# File 'lib/sketchup-api-stubs/stubs/UI/Notification.rb', line 156

def on_accept(title, block)
end

#on_accept_titleString

Returns the accept’s button title.

Examples:

notification = UI::Notification.new(sketchup_extension, "Hello world")
notification.on_accept("Accept")  do |notification, title|
   puts "The user pressed #{notification.on_accept_title}"
end
notification.show

Returns:

Version:

  • SketchUp 2017



171
172
# File 'lib/sketchup-api-stubs/stubs/UI/Notification.rb', line 171

def on_accept_title
end

#on_dismiss(title, block) ⇒ Boolean

Shows a button in the notification with the given title and callback block, both arguments are required.

Examples:

notification = UI::Notification.new(sketchup_extension, "Hello world")
notification.on_dismiss("Close")  do |notification, title|
   puts "The user pressed [#{title}] with message #{notification.message}"
end
notification.show

Parameters:

  • title (String)

    Sets the title of the button.

  • block (Block)

    Sets the action callback, this will be called when the user clicks on the dismiss button.

Returns:

  • (Boolean)

Raises:

  • (RuntimeError)

    When calling on_dismiss when the notification has already been shown.

Version:

  • SketchUp 2017



197
198
# File 'lib/sketchup-api-stubs/stubs/UI/Notification.rb', line 197

def on_dismiss(title, block)
end

#on_dismiss_titleString

Returns the dismiss’s button title.

Examples:

notification = UI::Notification.new(sketchup_extension, "Hello world")
notification.on_dismiss("Close")  do |notification, title|
   puts "The user pressed #{notification.on_dismiss_title}"
end
notification.show

Returns:

Version:

  • SketchUp 2017



212
213
# File 'lib/sketchup-api-stubs/stubs/UI/Notification.rb', line 212

def on_dismiss_title
end

#showBoolean

Shows the notification in the top right of the screen, the notifications will be ordered from top to bottom if multiple notifications are shown, it will automatically be dismissed if no action is taken.

Examples:

notification = UI::Notification.new(sketchup_extension, "Hello world")
notification.show

Returns:

  • (Boolean)

Version:

  • SketchUp 2017



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

def show
end