Class: UI::WebDialog Deprecated
- Inherits:
-
Object
- Object
- UI::WebDialog
- Defined in:
- lib/sketchup-api-stubs/stubs/UI/WebDialog.rb
Overview
Please use HtmlDialog that was introduced in SketchUp 2017.
The Ruby WebDialog class allows you to create and interact with DHTML dialog boxes from Ruby.
If your goal is to simply display a website to your users, consider using openURL, which will show them a web page in their default browser rather than inside a dialog in SketchUp.
See this blog post for a detailed, step-by-step example: sketchupapi.blogspot.com/2008/02/sharing-data-between-sketchup-ruby-and.html
Under Windows the IE render mode is different in webdialogs than from what you see in the normal browser. It will by default pick an older render mode and different versions of SketchUp will use different modes. In order to reliably control the render mode of your webdialogs under Windows you need to insert a special META compatibility tag:
// To always force the latest version available:
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
// To lock to a specific IE version:
<meta http-equiv="X-UA-Compatible" content="IE=8"/>
Starting with SketchUp 2013, you can embed a special HTML link in your dialog that will launch Extension Warehouse and show a specified extension’s page. This can be useful if your extension has a dependency on another one and you would like to direct the user to install that extension.
For example, to launch an extension’s page whose URL is: extensions.sketchup.com/en/content/advanced-camera-tools The link would be:
Instance Method Summary collapse
-
#add_action_callback(callback_name) {|dialog, params| ... } ⇒ Object
The add_action_callback method establishes a Ruby callback method that your web dialog can call to perform some function.
-
#allow_actions_from_host(hostname) ⇒ Boolean
By default, actions are only allowed on the host where the webdialog is displayed.
-
#bring_to_front ⇒ UI::WebDialog
The bring_to_front method is used to bring the webdialog to the front of all the windows on the desktop.
-
#close ⇒ nil
The close method is used to close the webdialog.
-
#execute_script(script) ⇒ Boolean
The execute_script method is used to execute a JavaScript string on the web dialog.
-
#get_default_dialog_color ⇒ String
The get_default_dialog_color method is used to get the default dialog color for the web dialog.
-
#get_element_value(element_id) ⇒ String
The get_element_value method is used to get a value, with a given element_id, from the web dialog’s DOM.
-
#initialize(*args) ⇒ WebDialog
constructor
The
new
method is used to create a new webdialog. -
#max_height ⇒ Integer
The max_height method is used to get the maximum height that the user is allowed to resize the dialog to.
-
#max_height=(height) ⇒ Integer
The max_height= method is used to set the maximum height that the user is allowed to resize the dialog to.
-
#max_width ⇒ Integer
The max_width method is used to get the maximum width that the user is allowed to resize the dialog to.
-
#max_width=(width) ⇒ Integer
The max_width= method is used to set the maximum width that the user is allowed to resize the dialog to.
-
#min_height ⇒ Integer
The min_width method is used to get the minimum height that the user is allowed to resize the dialog to.
-
#min_height=(height) ⇒ Integer
The min_height= method is used to set the minimum height that the user is allowed to resize the dialog to.
-
#min_width ⇒ Integer
The min_width method is used to get the minimum width that the user is allowed to resize the dialog to.
-
#min_width=(width) ⇒ Integer
The min_width= method is used to set the minimum width that the user is allowed to resize the dialog to.
-
#navigation_buttons_enabled=(nav_buttons) ⇒ Boolean
The navigation_buttons_enabled= method is used to set whether the home, next, and back buttons are visible at the top of the WebDialog on the mac.
-
#navigation_buttons_enabled? ⇒ Boolean
The navigation_buttons_enabled? method is used to get whether the home, next, and back buttons are visible at the top of the WebDialog on the mac.
-
#post_url(url, data) ⇒ nil
The post_url method is used to send the data to a url using the HTTP POST method.
-
#screen_scale_factor ⇒ Float
The screen_scale_factor method returns the ratio of screen pixels to logical window units (called ‘points’ on Mac) for the screen this WebDialog is currently in.
-
#set_background_color(color) ⇒ nil
The set_background_color method is used to set the background color for the webdialog.
-
#set_file(filename, path = nil) ⇒ nil
The #set_file method is used to identify a local HTML file to display in the webdialog.
-
#set_full_security ⇒ UI::WebDialog
The set_full_security method is used to place the WebDialog into a higher security mode where remote URLs and plugins (such as Flash) are not allowed inside the browser.
-
#set_html(html_string) ⇒ nil
The set_html method is used to load a webdialog with a string of provided HTML.
-
#set_on_close { ... } ⇒ nil
The set_on_close method is used to establish one or more activities to perform when the dialog closes (such as saving values stored in the dialog).
-
#set_position(left, top) ⇒ nil
The set_position method is used to set the position of the webdialog relative to the screen, in pixels.
-
#set_size(w, h) ⇒ nil
The set_size method is used to set the size of the webdialog, in pixels.
-
#set_url(url) ⇒ nil
The set_url method is used to load a webdialog with the content at a specific URL.
-
#show {|dialog| ... } ⇒ nil
The show method is used to display a non-modal dialog box.
-
#show_modal {|dialog| ... } ⇒ nil
The show_modal method is used to display a modal dialog box.
-
#visible? ⇒ Boolean
The visible? method is used to tell if the webdialog is currently shown.
-
#write_image(image_path, option, top_left_x, top_left_y, bottom_right_x, bottom_right_y) ⇒ Object
The write_image method is used to grab a portion of the web dialog screen and save the image to the given file path.
Constructor Details
#initialize(dialog_title = "", scrollable = true, pref_key = nil, width = 250, height = ) ⇒ WebDialog #initialize(properties) ⇒ UI::WebDialog
Since SU2017 the position and size of the dialog is DPI aware - it will scale to the DPI of the monitor automatically. Specify units as they would be on a traditional low-DPI monitor.
The browser which is embedded inside the dialog depends on the user’s OS. On Mac, Safari is embedded, while on the PC whatever version of Internet Explorer is installed will be embedded.
The new
method is used to create a new webdialog.
250, left = 0, top = 0, resizable = true)
@param [String] dialog_title The title to be displayed in the webdialog.
@param [Boolean] scrollable true if you want to allow scrollbars, false
if you do not want to allow scrollbars.
@param [String, nil] pref_key The registry entry where the location and
size of the dialog will be saved.
If preferences_key is not included, the
location and size will not be stored.
@param [Integer] width The width of the webdialog.
@param [Integer] height The height of the webdialog.
@param [Integer] left The number of pixels from the left.
@param [Integer] top The number of pixels from the top.
@param [Integer] resizable true if you want the webdialog to be resizable,
false if not.
@return [UI::WebDialog]
235 236 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 235 def initialize(*args) end |
Instance Method Details
#add_action_callback(callback_name) {|dialog, params| ... } ⇒ Object
The add_action_callback method establishes a Ruby callback method that your web dialog can call to perform some function.
Use the skp:callback_method_name to invoke the callback method from your webdialog. Your JavaScript in the webdialog will invoke the callback method with a string representing arguments to the callback method.
Note that you’re sending data down to Ruby as a single string that’s passed via the window.location bar. In Internet Explorer on PC, there is a length limit of 2038 characters for this bar, so if you’re needing to pass large data down you might consider using get_element_value to pull in a longer string from a hidden input field in the HTML.
84 85 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 84 def add_action_callback(callback_name) end |
#allow_actions_from_host(hostname) ⇒ Boolean
By default, actions are only allowed on the host where the webdialog is displayed. The allow_actions_from_host method is used to selectively allow actions to take place on a host remote from the host where the webdialog exists. If the webdialog is local, no remote host is allowed unless you use this method.
103 104 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 103 def allow_actions_from_host(hostname) end |
#bring_to_front ⇒ UI::WebDialog
The bring_to_front method is used to bring the webdialog to the front of all the windows on the desktop. See show_modal for how to ensure that your WedDialogs are on top.
116 117 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 116 def bring_to_front end |
#close ⇒ nil
The close method is used to close the webdialog.
127 128 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 127 def close end |
#execute_script(script) ⇒ Boolean
The execute_script method is used to execute a JavaScript string on the web dialog.
143 144 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 143 def execute_script(script) end |
#get_default_dialog_color ⇒ String
The get_default_dialog_color method is used to get the default dialog color for the web dialog.
156 157 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 156 def get_default_dialog_color end |
#get_element_value(element_id) ⇒ String
The get_element_value method is used to get a value, with a given element_id, from the web dialog’s DOM.
175 176 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 175 def get_element_value(element_id) end |
#max_height ⇒ Integer
The max_height method is used to get the maximum height that the user is allowed to resize the dialog to.
247 248 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 247 def max_height end |
#max_height=(height) ⇒ Integer
As of SU2017 this will automatically scale the height by the same factor as UI.scale_factor.
The max_height= method is used to set the maximum height that the user is allowed to resize the dialog to.
265 266 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 265 def max_height=(height) end |
#max_width ⇒ Integer
The max_width method is used to get the maximum width that the user is allowed to resize the dialog to.
277 278 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 277 def max_width end |
#max_width=(width) ⇒ Integer
As of SU2017 this will automatically scale the width by the same factor as UI.scale_factor.
The max_width= method is used to set the maximum width that the user is allowed to resize the dialog to.
295 296 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 295 def max_width=(width) end |
#min_height ⇒ Integer
The min_width method is used to get the minimum height that the user is allowed to resize the dialog to.
307 308 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 307 def min_height end |
#min_height=(height) ⇒ Integer
As of SU2017 this will automatically scale the height by the same factor as UI.scale_factor.
The min_height= method is used to set the minimum height that the user is allowed to resize the dialog to.
325 326 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 325 def min_height=(height) end |
#min_width ⇒ Integer
The min_width method is used to get the minimum width that the user is allowed to resize the dialog to.
337 338 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 337 def min_width end |
#min_width=(width) ⇒ Integer
As of SU2017 this will automatically scale the width by the same factor as UI.scale_factor.
The min_width= method is used to set the minimum width that the user is allowed to resize the dialog to.
355 356 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 355 def min_width=(width) end |
#navigation_buttons_enabled=(nav_buttons) ⇒ Boolean
The navigation_buttons_enabled= method is used to set whether the home, next, and back buttons are visible at the top of the WebDialog on the mac. This method has no use on the PC, as these buttons are never displayed.
368 369 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 368 def () end |
#navigation_buttons_enabled? ⇒ Boolean
The navigation_buttons_enabled? method is used to get whether the home, next, and back buttons are visible at the top of the WebDialog on the mac. This method has no use on the PC, as these buttons are never displayed.
On the mac, this defaults to true for new WebDialogs.
383 384 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 383 def end |
#post_url(url, data) ⇒ nil
The post_url method is used to send the data to a url using the HTTP POST method.
401 402 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 401 def post_url(url, data) end |
#screen_scale_factor ⇒ Float
The screen_scale_factor method returns the ratio of screen pixels to logical window units (called ‘points’ on Mac) for the screen this WebDialog is currently in. On a retina screen Mac, this ratio will be greater than 1.0. On Windows this always return 1.0.
415 416 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 415 def screen_scale_factor end |
#set_background_color(color) ⇒ nil
The set_background_color method is used to set the background color for the webdialog.
430 431 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 430 def set_background_color(color) end |
#set_file(filename, path = nil) ⇒ nil
The #set_file method is used to identify a local HTML file to display in the webdialog.
449 450 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 449 def set_file(filename, path = nil) end |
#set_full_security ⇒ UI::WebDialog
The set_full_security method is used to place the WebDialog into a higher security mode where remote URLs and plugins (such as Flash) are not allowed inside the browser. This defaults to false when a new WebDialog is created.
462 463 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 462 def set_full_security end |
#set_html(html_string) ⇒ nil
The set_html method is used to load a webdialog with a string of provided HTML.
478 479 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 478 def set_html(html_string) end |
#set_on_close { ... } ⇒ nil
The set_on_close method is used to establish one or more activities to perform when the dialog closes (such as saving values stored in the dialog).
492 493 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 492 def set_on_close end |
#set_position(left, top) ⇒ nil
As of SU2017 this will automatically scale the x and y by the same factor as UI.scale_factor.
The set_position method is used to set the position of the webdialog relative to the screen, in pixels.
513 514 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 513 def set_position(left, top) end |
#set_size(w, h) ⇒ nil
As of SU2017 this will automatically scale the width and height by the same factor as UI.scale_factor.
The set_size method is used to set the size of the webdialog, in pixels.
533 534 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 533 def set_size(w, h) end |
#set_url(url) ⇒ nil
The set_url method is used to load a webdialog with the content at a specific URL. This method allows you to load web sites in a webdialog.
548 549 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 548 def set_url(url) end |
#show {|dialog| ... } ⇒ nil
The show method is used to display a non-modal dialog box.
564 565 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 564 def show end |
#show_modal {|dialog| ... } ⇒ nil
The show_modal method is used to display a modal dialog box. In SketchUp 6 and 7, this behaves differently on Mac vs. PC. On the PC, it shows a truly modal dialog, meaning so long as the WebDialog is visible, no input can be performed elsewhere inside SketchUp. On the Mac, “modal” WebDialogs do not behave this way, but instead are “always on top” of other windows.
584 585 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 584 def show_modal end |
#visible? ⇒ Boolean
The visible? method is used to tell if the webdialog is currently shown.
595 596 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 595 def visible? end |
#write_image(image_path, option, top_left_x, top_left_y, bottom_right_x, bottom_right_y) ⇒ Object
The write_image method is used to grab a portion of the web dialog screen and save the image to the given file path.
632 633 |
# File 'lib/sketchup-api-stubs/stubs/UI/WebDialog.rb', line 632 def write_image(image_path, option, top_left_x, top_left_y, bottom_right_x, bottom_right_y) end |