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

    Read_default webdialog position on OSX

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 4 Posters 292 Views 4 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.
    • jiminy-billy-bobJ Offline
      jiminy-billy-bob
      last edited by

      Can one read that on mac ? (Doesn't work on windows registry)
      Sketchup.read_default("WebDialog_whatever", "Left")

      25% off Skatter for SketchUcation Premium Members

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

        There's no Ruby-side method to read a webdialog's position, you can just set its position.
        You can get the window's position on the js-side, then pass that back to Ruby with a suitable callback...
        Ruby-side:

        @dlg.add_action_callback('window_position'){|d, p|
          self.do_something_with_window_position(p)
        }
        ###
        def self.do_something_with_window_position(p)
          ### 'write_default' with 'p' as the string - e.g. "123,456"
        end
        ### just before making the dlg 'read_default' to get 'p' - e.g. "123,456" 
        ### - use a default - say "20,20" if it is the first time, so no key/value...
        ### then...
          a = p.split(',')
          x = a[0].to_i
          y = a[1].to_i
        ### position the dlg thus;
          @dlg.set_position = x, y
        
        

        JS-side [jquery example]:

        $(window).bind("beforeunload", function(e) { 
          window.location = 'skp;window_position@'+(window.screen.left)+','+(window.screen.top);
        });
        

        So just before the window closes the callback gets the current x,y...

        If you then store these with 'write_default' the dlg's window can be opened in the same position as last time on MAC [read_default] - it already is for a named dlg on the PC ?

        TIG

        1 Reply Last reply Reply Quote 0
        • tt_suT Offline
          tt_su
          last edited by

          I think I have a trick up my sleeve... but not on this machine... 😕

          1 Reply Last reply Reply Quote 0
          • jiminy-billy-bobJ Offline
            jiminy-billy-bob
            last edited by

            Thanks TIG!
            I was thinking about using something like that, but it has to consider the window border.

            25% off Skatter for SketchUcation Premium Members

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

              @jiminy-billy-bob said:

              it has to consider the window border.

              macs don't have window borders...

              available using vanilia.js from one of my webDialogs...

              outerHeight; 370
              outerWidth; 422
              pageXOffset; 0
              pageYOffset; 0
              parent; Window
              parseFloat; function parseFloat() {
              parseInt; function parseInt() {
              personalbar; BarProp
              constructor; BarPropConstructor
              visible; false
              __proto__; BarPropPrototype
              screen; Screen
              availHeight; 1174
              availLeft; 0
              availTop; 22
              availWidth; 1920
              colorDepth; 24
              constructor; ScreenConstructor
              height; 1200
              pixelDepth; 24
              width; 1920
              __proto__; ScreenPrototype
              screenLeft; 100
              screenTop; 420
              screenX; 100
              screenY; 420
              scrollX; 0
              scrollY; 0
              scr
              

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

              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