sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Center Webdialog over Sketchup window

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 406 Views 3 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.
    • M Offline
      maricanis
      last edited by

      Hi,

      I need my WebDialog to be centered over SketchUp window each time it is opened.

      I've tried to find similar posts, without success (I found how to center over screen
      http://www.sketchucation.com/forums/scf/viewtopic.php?f=26%26amp;t=6067, but not how to center over Sketchup window). Are there some functions in Ruby API for that or should use some Windows API functions?

      So my question is how to get position and size of Sketchup application window?
      Once I have that info I can easily do WebDialog positioning.

      Marija.

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        The methods Sketchup.active_model.active_view.vpwidth and .vpheight give you the dims of the current pane in pixels.
        As you say... half those to get the center.
        Deduct from those half the web-dialog's width or its height to get the top left corner location, to move the webdialog to, using http://www.sketchup.com/intl/en/developer/docs/ourdoc/webdialog#set_position
        BUT if the SKP window is not maximized then you could have problems ?
        You then need to use WIN/MAC system calls to find the location of the SKP's window itself... πŸ˜’

        TIG

        1 Reply Last reply Reply Quote 0
        • M Offline
          maricanis
          last edited by

          Hi TIG,

          I know about active_view, but problem is if dialog is not maximized and if/when it is moved from screen center.
          Definitely Windows system calls are needed. I'm now experimenting on that and I hope to find some solution soon.

          Thanks

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

            You could theoretically read the screen dimensions using JavaScript, divide by two and subtract half of the dialog's width and height (you can read the inner width without window border using JavaScript).

            This is not recommended. If it is not essential to the functioning of you plugin, think again if you can get along without it. This causes your dialog to launch initially with different dimensions and then "jump". On a multi-monitor setup, you don't know whether the dialog is on the second monitor, and the above formula will give you coordinates for the first monitor. The dialog will jump to the first monitor, if it was launched (by registry preferences) on the second one.

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

            Advertisement