ModraUp Ruby API Documentation Ruby API Reference

Class: UI::HtmlPanel

Inherits:
Object
  • Object
show all

Overview

HTML panel in the Ruby UI workspace. SketchUp does not have this class.

Note: ModraUp extension.

Examples:

panel = UI::HtmlPanel.new(title: "Properties", height: 160)
panel.set_html("<p>panel</p>")
panel.show

Class Method Summary # collapse

Instance Method Summary # collapse

Class Method Details

HtmlPanel.new(properties = {}) ⇒ panel

Hash keys: title / preferences_key / height (integer or :auto) / fill_height.

Parameters:

  • properties (Hash)

Returns:

  • (UI::HtmlPanel)

Raises:

  • [RuntimeError] No UI bridge available.
Note: ModraUp extension.

Examples:

UI::HtmlPanel.new(title: "Properties", height: :auto)

Instance Method Details

panel.set_html(html) ⇒ nil

Load the HTML string.

Parameters:

  • html (String)

Returns:

  • (nil)
Note: ModraUp extension.

Examples:

UI::HtmlPanel.new.set_html("<p>hi</p>")

panel.set_file(path) ⇒ nil

Load from a local file.

Parameters:

  • path (String)

Returns:

  • (nil)
Note: ModraUp extension.

Examples:

UI::HtmlPanel.new.set_file(File.join(__dir__, "tray.html"))

panel.set_url(url) ⇒ nil

Load the URL.

Parameters:

  • url (String)

Returns:

  • (nil)
Note: ModraUp extension.

Examples:

UI::HtmlPanel.new.set_url("https://example.com")

panel.show ⇒ nil

Shows the tray panel.

Returns:

  • (nil)
Note: ModraUp extension.

Examples:

UI::HtmlPanel.new.show

panel.hide ⇒ nil

Hides the tray panel.

Returns:

  • (nil)
Note: ModraUp extension.

Examples:

UI::HtmlPanel.new.hide

panel.close ⇒ nil

Close and destroy.

Returns:

  • (nil)
Note: ModraUp extension.

Examples:

UI::HtmlPanel.new.close

panel.visible? ⇒ Boolean

Visibility.

Returns:

  • (Boolean)
Note: ModraUp extension.

Examples:

UI::HtmlPanel.new.visible?

panel.execute_script(script) ⇒ nil

Execute JavaScript in the page.

Parameters:

  • script (String)

Returns:

  • (nil)
Note: ModraUp extension.

Examples:

UI::HtmlPanel.new.execute_script("console.log(1)")

panel.add_action_callback(name) {|context, *args| } ⇒ true

Register a JS-callable callback.

Parameters:

  • name (String)

Returns:

  • (true)

Yields:

  • @yieldparam context [nil]

Raises:

  • [ArgumentError] No block provided
Note: ModraUp extension.

Examples:

panel = UI::HtmlPanel.new
panel.add_action_callback("ok") { |_, v| puts v }

panel.set_on_closed { } ⇒ true

A block to be called when the dialog is closed.

Returns:

  • (true)

Raises:

  • [ArgumentError] No block provided
Note: ModraUp extension.

Examples:

UI::HtmlPanel.new.set_on_closed { }