sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    How to make a frame/dialog/window always on top?

    Scheduled Pinned Locked Moved Developers' Forum
    23 Posts 7 Posters 2.7k Views 7 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.
    • thomthomT Offline
      thomthom
      last edited by

      @alexmojaki said:

      Well, for me it's not even showing on top of the main Sketchup window. I have no other dialogs open, the only other window is Sketchup itself. And when I click on it, the dialog disappears right behind it.

      hm... you sure you didn't use show()?

      If you try this base bone example:
      w=UI::WebDialog.new('test').show_modal

      If that doesn't produce a WebDialog that keep on top of SketchUp; what OSX do you have?

      Btw, while on topic of Webdialogs, have you seen this thread: http://sketchucation.com/forums/viewtopic.php?f=180&t=23445#p198883
      ?

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • A Offline
        alexmojaki
        last edited by

        Yes, I've seen the lost manual. What was critical to me at the beginning of the thread was that show in Windows kept the dialog on top (which isn't obvious), maybe add that to the manual.

        OK, I edited the wrong file when I was testing show_modal. So it works correctly. Then I discovered that the problem with my code is that for some reason when I reclick on the object to put Sketchup in focus, for some reason onSelectionCleared gets called, and then immediately after onSelectionBulkChange. I have no idea why: as far as I can see the selection never gets cleared. So the dialog was actually being closed, and then it wasn't opened again because I didn't edit @prevSelection when the selection was cleared. But now that I've done that, I'm back to the original problem: each time I click on the object to try and put Sketchup in focus, the dialog is closed and reopened and so regains focus.

        So now it seems my main problem is that the selection is momentarily cleared unnecessarily. In fact, I tested a bit more and found that it seems to get cleared pretty much all the time. It hasn't even got anything to do with the dialog or reclicking, onSelectionCleared gets called whenever I change my selection at all. I need to keep the definition because onSelectionBulkChange doesn't react to clicking an empty space. So I need a way to distinguish between the selection being genuinely cleared and this quirk. I considered InputPoint, but I've never used that before and I don't see how it can be used from the context of a SelectionObserver.

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          hm... I've noticed that the Selection observers misbehaves: http://www.thomthom.net/software/sketchup/observers/

          (Btw - I have other observations I've not published yet. Available in the BitBucket repo: https://bitbucket.org/thomthom/sketchup-observers/issues?status=new&status=open)

          Thomas Thomassen — SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • D Offline
            driven
            last edited by

            on the mac show_modal and bring_to_front appears on top of everything, so they're really the same except one returns 'true' and the other returns the object.

            > webdialog=UI;;WebDialog.new('blur_focus')
            
            #<UI;;WebDialog;0x110e2a48>
            > webdialog.show
            true
            > webdialog.show_modal
            true
            > webdialog.bring_to_front
            #<UI;;WebDialog;0x110e2a48>
            > webdialog.execute_script('window.focus()')
            true
            > webdialog.show_modal
            webdialog.execute_script('window.blur()')
            true
            > webdialog.close
            nil
            
            

            'window.focus()' and 'window.blur()' work with 'show', 'show_modal' or 'bring_to_front', so you can do stuff like

            > webdialog.set_html("Hi!")
            webdialog.execute_script('window.blur()')
            true
            > webdialog.set_html("Bye!")
            webdialog.execute_script('window.blur()')
            true
            > webdialog.set_html("Hi!")
            webdialog.bring_to_front
            webdialog.execute_script('window.blur()')
            true
            > webdialog.set_html("I'm going to hide!")
            webdialog.close
            webdialog.execute_script('window.blur()')
            true
            > webdialog.show
            true
            

            just say if I'm 'barking up the wrong tree'
            john

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

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by

              @alexmojaki said:

              OK, I edited the wrong file when I was testing show_modal. So it works correctly.
              Yup! Been there, done that, just yesterday, in fact (edited the wrong Js function and wondered why things did not change.)

              @alexmojaki said:

              Then I discovered that the problem with my code is that for some reason when I reclick on the object to put Sketchup in focus, for some reason onSelectionCleared gets called, and then immediately after onSelectionBulkChange. I have no idea why ... So now it seems my main problem is that the selection is momentarily cleared unnecessarily. ... onSelectionCleared gets called whenever I change my selection at all.
              This is expected. The selection must be cleared in order to receive the elements for the new selection, regardless of whether they are the same as the old selection.

              @alexmojaki said:

              So I need a way to distinguish between the selection being genuinely cleared and this quirk.
              Sketchup::ToolsObserver
              The SelectionTool is tool id #21022
              You might get some benefit from watching the tool state (integer) changes.

              Also the Sketchup::Tools collection, might help.
              But be sure you always check that active_tool_id != 0 before attempting to access active_tool_name() (if active tool is undefined, trying to get a name string can BugSplat! SketchUp.)

              @alexmojaki said:

              Is wxSU my only option?
              Not for Mac, which is where you had the Z-order problem. AFAIK, it is still MS Windows only. (Unless they've gotten it working on the Mac now?)

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                @driven said:

                on the mac show_modal and bring_to_front appears on top of everything, so they're really the same except one returns 'true' and the other returns the object.

                Not the same. If you have a dialog opened with show then call bring_to_front then it will put the window at the top of the stack. But if you click the SketchUp window it'll appear above the WebDialog.
                If you use show_modal then the webdialog will never drop behind the sketchup window.

                Thomas Thomassen — SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • D Offline
                  driven
                  last edited by

                  @thomthom said:

                  Not the same. If you have a dialog opened with show then call bring_to_front then it will put the window at the top of the stack. But if you click the SketchUp window it'll appear above the WebDialog.

                  I stand corrected... if acting on a previously show_modal, then bring_to_front will stay on top.

                  ` > webdialog=UI::WebDialog.new('blur_focus')
                  webdialog.set_html("You'll only see me flash!
                  but I'll exist in a 'show_modal' state")
                  webdialog.show_modal
                  webdialog.close
                  nil

                  webdialog.set_html("You'll see me, and because I was 'show_modal' to start with, I'll behave like a 'show_modal' dialog!
                  However, I won't have focus, because 'window.blur()' has been called")
                  webdialog.bring_to_front
                  webdialog.execute_script('window.blur()')
                  true`

                  My main point was that blur and focus can be set independently of the show-status.
                  john

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

                  1 Reply Last reply Reply Quote 0
                  • A Offline
                    alexmojaki
                    last edited by

                    webdialog.execute_script('window.blur()') solves everything instantly. Did not know I could do that. Thanks a lot, driven!

                    Thanks also to others for staying with my problem for so long.

                    And yes, wxSU is available for Mac.

                    Incidentally, I haven't tested any of this on Windows yet, so we'll see what happens when I try there. This might not be over yet.

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      driven
                      last edited by

                      @alexmojaki said:

                      [Thanks a lot, driven!

                      Glad to assist, I'm not a rubyist, but I do alot of mac testing, and ('window.blur()') buggered something up recently, so I tested ('window.focus()') to try to fix that and it was fresh in my mind... chance

                      @unknownuser said:

                      And yes, wxSU is available for Mac.

                      whenever I've tested anything to do with wxSU it plays havoc on the mac, it can work, but little else will after installing it, I now treat it with the same contempt as a lot of people treat MacPorts... use at your own peril.

                      john

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

                      1 Reply Last reply Reply Quote 0
                      • A Offline
                        alexmojaki
                        last edited by

                        @alexmojaki said:

                        Incidentally, I haven't tested any of this on Windows yet, so we'll see what happens when I try there. This might not be over yet.

                        Aaaand...I'm back! Indeed, this solution doesn't really work on Windows, because as soon as window.blur() is called, it doesn't just remove focus from the dialog, but from the whole Sketchup application! Sketchup goes into the background, yet somehow it is the window that is open according to the taskbar, and if you click on it in the taskbar to try and reopen it it minimises it.

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

                        Advertisement