Web Dialogs: cancelling at onclose
-
If you close a Web dialog via the close button in its title bar, the only event you get is a call to the callback you set with
set_on_close()
.However, there seems to be no way to cancel the effective closing of the window if you wish to.
The only possibility is to Show again the dialog box asynchronously (
show()
orshow_modal()
)Note: you need to re-execute some Javascript to update the latest state, as the dialog box is shown with its initial HTML state, based passed via
set_html()
)This works OK for the visual, but it then takes several seconds to get the mouse events active in the dialog box. Very strange!
So my question is whether someone has found a way to avoid the closing of a Web dialog or a better method?
EDIT: I don't have an explanation for the delay to get the mouse event back. The workaround is to redo a
set_html
before theshow()
. Then no delay. -
Maybe detect closing of the webdialog in javascript instead?
<body onUnload = call_ruby('quit');>
Another option could be: instead of closing the webdialog, you could minimize it so it just show the title bar, and a maximize icon. This way, the tool is still active and the user gets some screen space back until he/she has to make another choice in the webdialog and can maximize it again.
-
does webdialog.bring_to_front not work?
-
There are probably javascript / jquery ways of making a 'frameless' window [like a tooltip / popup], but then be sure to add a closing button within it - perhaps as it 'confirms' ?
You could maybe have the normally titled/framed parent window opening off-screen and its child title-less and frameless custom window opening on-screen ?
When this child is 'confirmed' and it somehow closes it also closes the off-screen parent ?There are lots of half-baked examples on the http://www...
-
TIG,
This is not about detecting the closing. the callback defined in
set_on_close()
is invoked. So I know theere is a request for close.The question is that there seems to be no way to prevent the closing itself.
The case is that when the web dialog window closes, I ask for confirmation on Save with a Yes, NO, CANCEL. Simply, the CANCEL, that is, cancel closing, is not straightforward to do.
The workaround to reload the HTML by
set_html
works however, if you call it asyncronously (with aUI.start_timer(0)
.Fredo
-
I'm sure it is possible to modify webdialog's window procedure through Windows API and handle/make decisions to the WM_CLOSE/WM_QUIT messages from there. One problem is that such technique will not work on Mac OS X. It will only work on Windows OS. If you're interested, I could write a sample.
-
Anton,
Thanks. It's a pity that there is no built-in mechanism (such as the return value of the callback defined in
set_on_close
). We can also understand that SU wants to preserve a way to close the web dialog 'whatever' in case of trouble.Anyway, reloading the HTML works fine. I just noticed that redoing just a
show()
create this delay in capturing mouse events.Fredo
Advertisement