Module: UI
Overview
Host interface for menus, dialogs, toolbars, HTML windows, clipboard access, and timers.
Defined Under Namespace
Classes: Command, HtmlDialog, HtmlPanel, Notification, Toolbar, WebDialog
Constants # collapse
- UI::MB_OK
MB_OK = 0
UI.messagebox:OK only.
- UI::MB_OKCANCEL
MB_OKCANCEL = 1
UI.messagebox:OK / Cancel.
- UI::MB_ABORTRETRYIGNORE
MB_ABORTRETRYIGNORE = 2
UI.messagebox:Abort / Retry / Ignore.
- UI::MB_YESNOCANCEL
MB_YESNOCANCEL = 3
UI.messagebox:yes / no / cancel.
- UI::MB_YESNO
MB_YESNO = 4
UI.messagebox:Yes / No.
- UI::MB_RETRYCANCEL
MB_RETRYCANCEL = 5
UI.messagebox:Retry / Cancel.
- UI::MB_MULTILINE
MB_MULTILINE = 6
UI.messagebox:multi-line text.
- UI::IDOK
IDOK = 1
UI.messagebox returns: OK.
- UI::IDCANCEL
The cancel value corresponding to IDOK.
- UI::IDABORT
Return value of UI.messagebox when the user chooses Abort.
- UI::IDRETRY
Return value of UI.messagebox when the user chooses Retry.
- UI::IDIGNORE
Return value of UI.messagebox when the user chooses Ignore.
- UI::IDYES
Return value of UI.messagebox when the user chooses Yes.
- UI::IDNO
Return value of UI.messagebox when the user chooses No.
- UI::TB_HIDDEN
TB_HIDDEN = 0
The toolbar's last state: Hidden. See UI::Toolbar#get_last_state.
- UI::TB_VISIBLE
TB_VISIBLE = 1
Toolbar last state: Visible.
- UI::TB_NEVER_SHOWN
TB_NEVER_SHOWN = -1
The toolbar has never been shown.
Class Method Summary # collapse
-
.menu(name = "Extensions") ⇒ ModraUp::Menu
Fetch the top-level menu. Common entries include "Plugins" / "Extensions" / "Tools" / "View".
-
.messagebox(message) ⇒ Integer
Display a message box. Return IDOK if no host is present.
-
.inputbox(prompts) ⇒ Array<String, Integer, Float, Length>, false
Multiline input. Returns false if canceled or no host.
-
.openpanel(title = "Open", directory = nil, filename = nil) ⇒ String, nil
Open the file dialog box. Return nil if canceled.
-
.savepanel(title = "Save", directory = nil, filename = nil) ⇒ String, nil
Save file dialog. Cancel returns nil.
-
.select_directory(options = {}) ⇒ String, Array<String>, nil
Select directory. Hash key :title / :directory / :select_multiple.
-
.openURL(url) ⇒ Boolean
Open the URL in the system browser.
-
.beep ⇒ nil
System beep.
-
.play_sound(path) ⇒ nil
Plays a local sound file.
-
.start_timer(seconds, repeat = false) ⇒ Integer
Start the timer and return a handle to UI.stop_timer.
-
.stop_timer(id) ⇒ nil
Stop the timer returned by UI.start_timer.
-
.scale_factor ⇒ Numeric
Returns 1.0 (as of SketchUp 2025, this is compatible padding: screen coordinates are already logical pixels). When passed a {ModraUp::View}, returns the scale factor of the viewport's screen (commonly 2.0 on Retina displays).
-
.get_clipboard_data ⇒ String, nil
Read clipboard text.
-
.set_clipboard_data(text) ⇒ Boolean
Write text to the clipboard.
-
.create_cursor(path, hot_x, hot_y) ⇒ Integer
Create a cursor from an image file and return a handle to UI.set_cursor.
-
.set_cursor(id) ⇒ Boolean
Set the current cursor.
-
.toolbar(name) ⇒ UI::Toolbar
Retrieve the toolbar by name; if it doesn't exist, create one (category defaults to "Modeling").
-
.toolbar_names ⇒ Array<String>
The currently registered toolbar names.
-
.toolbar_visible?(name) ⇒ Boolean
Whether the toolbar is visible.
-
.set_toolbar_visible(name, visible) ⇒ Boolean
Show or hide the toolbar.
-
.refresh_toolbars ⇒ nil
Recalculate the enabled and checked states of the Ruby toolbar commands.
-
.refresh_inspectors ⇒ nil
Refresh the inspectors panel.
-
.inspector_names ⇒ Array<String>
Names of inspectors that can be opened.
-
.show_inspector(name) ⇒ Boolean
Open the specified inspector.
-
.model_info_pages ⇒ Array<String>
The page name for the model information dialog.
-
.show_model_info(page) ⇒ Boolean
Open the model information and switch to that page.
-
.preferences_pages ⇒ Array<String>
Name of the preference settings page.
-
.show_preferences(page) ⇒ Boolean
Open the preferences and switch to that page.
-
.show_extension_manager ⇒ nil
Open the Extension Manager.
-
.show_extension_warehouse ⇒ nil
Open the Extension Warehouse (optionally navigate to a specific extension id).
-
.add_context_menu_handler ⇒ Integer
Right-click menu callback. Called by default on a right-click in the viewport when hitting a solid entity; not called if the current tool implements ModraUp::Tool#getMenu for blank areas or the current tool.
Class Method Details
UI.messagebox(message) ⇒ IntegerUI.messagebox(message, type) ⇒ IntegerUI.messagebox(message, type, title) ⇒ Integer
Display a message box. Return IDOK if no host is present.
UI.inputbox(prompts) ⇒ Array<String>, falseUI.inputbox(prompts, defaults) ⇒ Array, falseUI.inputbox(prompts, defaults, title) ⇒ Array, falseUI.inputbox(prompts, defaults, lists, title) ⇒ Array, false
Multiline input. Returns false if canceled or no host. Returns the default value for Integer, Float, and Length types; otherwise, returns the string. Fails with ArgumentError if numerical conversion fails.
UI.openpanel(title = "Open", directory = nil, filename = nil) ⇒ String, nil
Open the file dialog box. Return nil if canceled.
UI.savepanel(title = "Save", directory = nil, filename = nil) ⇒ String, nil
Save file dialog. Cancel returns nil.
UI.select_directory(options = {}) ⇒ String, Array<String>, nil
Select directory. Hash key :title / :directory / :select_multiple. Multiple selection returns an array, otherwise returns a path.
UI.openURL(url) ⇒ Boolean
Open the URL in the system browser.
UI.beep ⇒ nil
System beep.
UI.play_sound(path) ⇒ nil
Plays a local sound file.
UI.start_timer(seconds, repeat = false) { } ⇒ Integer
Start the timer and return a handle to UI.stop_timer.
UI.stop_timer(id) ⇒ nil
Stop the timer returned by UI.start_timer.
UI.scale_factor ⇒ NumericUI.scale_factor(view) ⇒ Numeric
Returns 1.0 (as of SketchUp 2025, this is compatible padding: screen coordinates are already logical pixels). When passed a {ModraUp::View}, returns the scale factor of the viewport's screen (commonly 2.0 on Retina displays).
UI.get_clipboard_data ⇒ String, nil
Read clipboard text.
UI.set_clipboard_data(text) ⇒ Boolean
Write text to the clipboard.
UI.create_cursor(path, hot_x, hot_y) ⇒ Integer
Create a cursor from an image file and return a handle to UI.set_cursor.
UI.set_cursor(id) ⇒ Boolean
Set the current cursor.
UI.toolbar(name) ⇒ UI::Toolbar
Retrieve the toolbar by name; if it doesn't exist, create one (category defaults to "Modeling").
UI.toolbar_names ⇒ Array<String>
The currently registered toolbar names.
UI.toolbar_visible?(name) ⇒ Boolean
Whether the toolbar is visible.
UI.set_toolbar_visible(name, visible) ⇒ Boolean
Show or hide the toolbar.
UI.refresh_toolbars ⇒ nil
Recalculate the enabled and checked states of the Ruby toolbar commands.
UI.refresh_inspectors ⇒ nil
Refresh the inspectors panel.
UI.inspector_names ⇒ Array<String>
Names of inspectors that can be opened.
UI.show_inspector(name) ⇒ Boolean
Open the specified inspector.
UI.model_info_pages ⇒ Array<String>
The page name for the model information dialog.
UI.show_model_info(page) ⇒ Boolean
Open the model information and switch to that page.
UI.preferences_pages ⇒ Array<String>
Name of the preference settings page.
UI.show_preferences(page) ⇒ Boolean
Open the preferences and switch to that page.
UI.show_extension_manager ⇒ nil
Open the Extension Manager.
UI.show_extension_warehouse ⇒ nilUI.show_extension_warehouse(id) ⇒ nil
Open the Extension Warehouse (optionally navigate to a specific extension id).