I am writing a HtmlDialog
via Ruby
, but i can’t find the method of UI::HtmlDialog
in HtmlDialog to create the top bar just like this(i dont know the name of this).
what’s the #method of this ?
Thanks
you now need to ‘roll your own’ …
many WebDialog functions where not implemented for HtmlDialogs…
## navigation_buttons_enabled= is WebDialog only...
UI::WebDialog.public_instance_methods =
[:write_image, :set_size, :min_width, :min_width=, :close,
:min_height, :min_height=, :max_width, :max_width=,
:max_height, :show, :set_position, :visible?, :post_url,
:set_url, :show_modal, :get_element_value, :add_action_callback,
:get_default_dialog_color, :max_height=, :set_file,
:navigation_buttons_enabled=, :set_background_color, :set_html,
:navigation_buttons_enabled?, :execute_script,
:allow_actions_from_host, :set_on_close, :bring_to_front,
:set_full_security, :screen_scale_factor, :last_height,
:last_height=, :last_width, :last_width=]
UI::HtmlDialog.public_instance_methods =
[:show_modal, :add_action_callback, :set_position,
:execute_script, :bring_to_front, :set_can_close,
:set_on_closed, :set_size, :center, :close, :show,
:set_url, :visible?, :set_html, :set_file]
john
What is your use case? For a “web-like” user experience I would typically use an external web browser. For dialogs that feel native to the application I’d use other kind of navigation, like open additional windows or progressive disclosure, not web-like browsing with back, forward and home buttons.
I really agree that there are far better ways to handle content, now we have the ‘cross platform’ webkit engine in SU…
a drop down menu can now done with two tags and no javascript…
<details>
<summary>The toggle</summary>
The content.
</details>
<details open>
<summary>Another toggle</summary>
Expanded by default
</details>
john
i just need a simple UI, WebDialog
or HtmlDialog
is enough.
yes, i find the method
# **navigation_buttons_enabled= (nav_buttons) ⇒ Boolean
,
I tried dialog.navigation_buttons_enabled=true
, but makes no changes.
Does nav_buttons
a constant for SketchUp?
I need back
& front
& Home
.
I don’t believe the internal browsers used by WebDialog support this function any longer…
it was designed for IE and an old Safari [WebCore]
things move on…
john
It’s not necessarily any simpler to get a back, a forward and a home button than any other solution.
Yes, i only need a forward and home button.
Did you mean this function doesn’t work any more?
You can trigger Back and Forward via the JavaScript API:
window.history.back()
window.history.forward()
it no longer works for my OS supplied WebCore engine that SU has to use for ‘WebDialog’…
it is trivial to implement in ‘HtmlDialog’ as SU supplies the ‘CEF’ and all OS use that…
back/forward are right click options in ‘HtmlDialogs’ …
this in SU and you can see my Ruby Console on the right…
john
In your JavaScript …
function home() {
window.location = "https://some/valid/webpage.html";
}
function back() {
window.history.back();
}
function forward() {
window.history.forward();
}
And in the HTML …
<span>
<button onClick="home();">Home</button>
<button onClick="back();">Back</button>
<button onClick="forward();">Forward</button>
</span>
In your CSS stylesheet for the page set padding and margins to space the buttons.
i have another question in dialog.add_action_callback
.
# i have a button 'cancel' related to SketchUp
dialog.add_action_callback("cancel") do | action_context, num |
re = UI.messagebox("giving up downloading?", MB_YESNO) if num == 1
if re == 6 # click yes
request.cancel # download requeset canceled
dialog.close()
elsif re == 7 # click no
# this UI.messagebox continue jump out
# how do i do to avoid the message jumping out after i click 'no'
break
end
end
What do you mean by “jump out”?
Btw, if you compare against IDYES and IDNO instead of hardcoded numbers it is much easier to read the code.
after i click ‘no’, the messagebox jump again and again until i clock ‘yes’.
i have changed the hardcoded to IDYES&IDNO.
Then it appears the dialog is calling the callback repeatedly.
so i want to ‘jump out’ the callback if ‘no’ is clicked. But i am not sure whether it can be implemented:face_with_monocle:
The callback code should stop executing as soon as the code ends. A callback isn’t a loop repeating time after time by itself. It appears there is a bug in the javascript code that calls this callback.