• Login
sketchucation logo sketchucation
  • Login
🔌 Quick Selection | Try Didier Bur's reworked classic extension that supercharges selections in SketchUp Download

Web Dialogs: cancelling at onclose

Scheduled Pinned Locked Moved Developers' Forum
7 Posts 5 Posters 583 Views 5 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    fredo6
    last edited by 4 Oct 2015, 13:12

    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() or show_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 the show(). Then no delay.

    1 Reply Last reply Reply Quote 0
    • K Offline
      kaas
      last edited by 4 Oct 2015, 14:18

      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.

      1 Reply Last reply Reply Quote 0
      • D Offline
        driven
        last edited by 4 Oct 2015, 15:24

        does webdialog.bring_to_front not work?

        learn from the mistakes of others, you may not live long enough to make them all yourself...

        1 Reply Last reply Reply Quote 0
        • T Offline
          TIG Moderator
          last edited by 4 Oct 2015, 15:26

          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

          1 Reply Last reply Reply Quote 0
          • F Offline
            fredo6
            last edited by 4 Oct 2015, 16:22

            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 a UI.start_timer(0).

            Fredo

            1 Reply Last reply Reply Quote 0
            • A Offline
              Anton_S
              last edited by 6 Oct 2015, 07:38

              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.

              1 Reply Last reply Reply Quote 0
              • F Offline
                fredo6
                last edited by 6 Oct 2015, 09:14

                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

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                1 / 1
                • First post
                  1/7
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement