Class: UI::WebDialog废弃的
- 继承于:
-
Object
- Object
- UI::WebDialog
概述
请使用HtmlDialog that was introduced in SketchUp 2017.
Ruby WebDialog类允许你在Ruby中创建DHTML对话框并与之互动。
如果你的目标是向你的用户简单地显示一个网站,可以考虑使用openURL,这将在他们的默认浏览器中显示一个网页,而不是在SketchUp的对话框中。
请看这篇博文,里面有一个详细的、分步骤的例子。sketchupapi.blogspot.com/2008/02/sharing-data-between-sketchup-ruby-and.html
在Windows下,IE在webdialogs的渲染模式与你在普通浏览器中看到的不同。它默认会选择一个较早的渲染模式,不同版本的SketchUp会使用不同的模式。为了可靠地控制您在 Windows 下的 webdialogs 的渲染模式,您需要插入一个特殊的 META 兼容性标签。
// 始终强制使用最新的版本: <meta http-equiv="X-UA-Compatible" content="IE=edge"/> // 锁定一个特定的IE版本: <meta http-equiv="X-UA-Compatible" content="IE=8" />
从SketchUp 2013开始,您可以在您的对话框中嵌入一个特殊的HTML链接,以启动扩展仓库并显示指定的扩展页面。如果你的扩展与另一个扩展有依赖关系,并且你想引导用户安装该扩展,那么这就很有用。
例如,要启动一个扩展的页面,其URL是。extensions.sketchup.com/en/content/advanced-camera-tools该链接将是:
实例方法总结# collapse
-
#add_action_callback(callback_name) {|dialog, params| ... } ⇒ Object
add_action_callback方法建立了一个Ruby回调方法,你的网络对话框可以调用这个方法来执行一些功能。
-
#allow_actions_from_host(hostname) ⇒ Boolean
默认情况下,只允许在显示webdialog的主机上进行操作。
-
#bring_to_front⇒ UI::WebDialog
bring_to_front方法用于将webdialog带到桌面上所有窗口的前面。
-
#close⇒ nil
close方法用于关闭Webdialog。
-
#execute_script(script) ⇒ Boolean
execute_script方法用于在网页对话框中执行一个JavaScript字符串。
-
#get_default_dialog_color⇒ 字符串
get_default_dialog_color方法用于获取网页对话框的默认对话框颜色。
-
#get_element_value(element_id) ⇒ String
get_element_value方法用于从网页对话框的DOM中获得一个给定的element_id的值。
-
#initialize(*args) ⇒ Object
构造函数
该
new
方法是用来创建一个新的webdialog。 -
#max_height⇒ Integer
max_height方法用于获得允许用户调整对话框大小的最大高度。
-
#max_height=(height) ⇒ Integer
max_height=方法用于设置允许用户调整对话框大小的最大高度。
-
#max_width⇒ Integer
max_width方法用于获得允许用户调整对话框大小的最大宽度。
-
#max_width=(width) ⇒ Integer
max_width=方法用于设置允许用户调整对话框大小的最大宽度。
-
#min_height⇒ 整数
min_width方法用于获得允许用户调整对话框大小的最小高度。
-
#min_height=(height) ⇒ Integer
min_height=方法用于设置允许用户调整对话框大小的最小高度。
-
#min_width⇒ 整数
min_width方法用于获得允许用户调整对话框大小的最小宽度。
-
#min_width=(width) ⇒ Integer
min_width=方法用于设置允许用户调整对话框大小的最小宽度。
-
#navigation_buttons_enabled=(nav_buttons) ⇒ 布尔值
navigation_buttons_enabled=方法用于设置Mac上WebDialog顶部的home、next和back按钮是否可见。
-
#navigation_buttons_enabled?⇒ Boolean
navigation_buttons_enabled? 方法用于获取Mac上WebDialog顶部的home、next和back按钮是否可见。
-
#post_url(url, data) ⇒ nil
post_url方法用于使用HTTP POST方法将数据发送到一个url。
-
#screen_scale_factor⇒ Float
screen_scale_factor方法返回这个WebDialog当前所处屏幕的屏幕像素与逻辑窗口单位(在Mac上称为'点')的比率。
-
#set_background_color(color) ⇒ nil
set_background_color方法用于设置Webdialog的背景颜色。
-
#set_file(filename, path = nil) ⇒ nil
的#set_file方法是用来确定一个本地的HTML文件,以便在webdialog中显示。
-
#set_full_security⇒ UI::WebDialog
set_full_security方法用于将WebDialog放入一个更高的安全模式,在这个模式下,浏览器内不允许有远程URL和插件(如Flash)。
-
#set_html(html_string) ⇒ nil
set_html方法是用来加载一个带有所提供的HTML字符串的Webdialog。
-
#set_on_close{ ... } ⇒ nil
set_on_close方法用于建立一个或多个活动,以便在对话框关闭时执行(例如保存存储在对话框中的值)。
-
#set_position(left, top) ⇒ nil
set_position方法用于设置webdialog相对于屏幕的位置,单位是像素。
-
#set_size(w, h) ⇒ nil
set_size方法用于设置Webdialog的大小,单位是像素。
-
#set_url(url) ⇒ nil
set_url方法用于在一个特定的URL上加载一个带有内容的webdialog。
-
#show{|dialog| ... } ⇒ nil
show方法用于显示一个非模式的对话框。
-
#show_modal{|dialog| ... } ⇒ nil
show_modal方法用于显示一个模式化的对话框。
-
#visible?⇒ Boolean
visible?方法用于判断webdialog当前是否被显示。
-
#write_image(image_path, option, top_left_x, top_left_y, bottom_right_x, bottom_right_y) ⇒ 对象
write_image方法用于抓取网页对话框屏幕的一部分,并将图像保存到给定的文件路径。
构造函数细节
↑ #initialize(dialog_title = "", scrollable = true, pref_key = nil, width = 250, height = ) ⇒Object #initialize(properties) ⇒UI::WebDialog
自从SU2017年以来,对话框的位置和大小都是DPI感知的--它将自动根据显示器的DPI缩放。指定的单位与传统的低DPI显示器上的一样。
嵌入对话框中的浏览器取决于用户的操作系统。在Mac上,Safari被嵌入,而在PC上,无论安装了什么版本的Internet Explorer都会被嵌入。
新的new
方法被用来创建一个新的webdialog。
250, left = 0, top = 0, resizable = true)
@param [String] dialog_title 将在webdialog中显示的标题。@param [Boolean] scrollable 如果你想允许滚动条,则为true;如果你不想允许滚动条,则为false。@param [String, nil] pref_key 将保存对话框的位置和大小的注册表项。如果不包括preferences_key,将不保存位置和大小。@param [Integer] width Webdialog的宽度。@param [Integer] height 网络对话的高度。@param [Integer] left 从左边开始的像素数。@param [Integer] top 从顶部开始的像素数。@param [Integer] resizable 如果你想让webdialog可调整大小,则为true;如果不想,则为false。@return [UI::WebDialog]。
实例方法详情
↑#add_action_callback(callback_name) {|dialog, params| ... } ⇒Object
add_action_callback方法建立了一个Ruby回调方法,你的网页对话框可以调用它来执行一些功能。
使用skp:callback_method_name来从你的webdialog调用回调方法。你在webdialog中的JavaScript将用一个代表回调方法参数的字符串来调用回调方法。
请注意,你是以一个字符串的形式向Ruby发送数据,该字符串通过window.location bar传递。在PC上的Internet Explorer中,这个栏的长度限制为2038个字符,所以如果你需要传递大量的数据,你可以考虑使用get_element_value来从HTML中的隐藏输入字段拉入一个较长的字符串。
↑#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.
↑#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.
↑#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.
↑#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
As of SU2017 this will automatically scale the height by the same factor asUI.scale_factor.
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
As of SU2017 this will automatically scale the width by the same factor asUI.scale_factor.
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
As of SU2017 this will automatically scale the height by the same factor asUI.scale_factor.
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
As of SU2017 this will automatically scale the width by the same factor asUI.scale_factor.
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. This method has no use on the PC, as these buttons are never displayed.
↑#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.
↑#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. On a retina screen Mac, this ratio will be greater than 1.0. On Windows this always return 1.0.
↑#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_filemethod 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. This defaults to false when a new WebDialog is created.
↑#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
As of SU2017 this will automatically scale the x and y by the same factor asUI.scale_factor.
The set_position method is used to set the position of the webdialog relative to the screen, in pixels.
↑#set_size(w, h) ⇒nil
As of SU2017 this will automatically scale the width and height by the same factor asUI.scale_factor.
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. This method allows you to load web sites in a webdialog.
↑#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. 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.
↑#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.