Position of SU viewport versus computer screen
-
After so many SU versions, there is still now way to know where the top-left corner of the SU viewport versus the computer screen (that is taking into account the SU titlebar and toolbars, top and left)
Am I correct, or someone did crack it?
.
This would allow to have a positioning of web dialog boxes by reference to position of objects in the SU viewport.Currently Web dialogs only position by reference to the computer screen.
Fredo
-
Fredo,
there's still no cross platform methods that I know of...you can do this with a simple bin script that can run from the plugin sub-folder on a mac...
the
onLButtonDown
sends the x,y to the bin script, which returns the screen co-ords for the web dialog...# use a class to create a tool class ClicTool def activate puts 'ClickTool has been activated.' @clk_dlg = UI;;WebDialog.new # get the scale for retina @scale = @clk_dlg.screen_scale_factor.to_i p " @scale = #{@scale} " end #----------------------------------------------------------------------------------------# def set_dlg_position(mod_pt) # this utility reports the screen position of the last click, i.e. tthe one that invokes it... clk_pt = `/usr/local/bin/cliclick -r p;.`.split(/; /)[1].chomp!.split(',') msg = "mod_pt = #{mod_pt} and clk_pt = #{clk_pt}" w = 200 h = 100 @clk_dlg.set_html(msg) @clk_dlg.set_size(w, h) # play with positioning by pw = clk_pt[0].to_i - (w / 2) ph = clk_pt[1].to_i - (h / 2) @clk_dlg.set_position(pw, ph) @clk_dlg.show_modal end #----------------------------------------------------------------------------------------# def onLButtonDown(_flags, x, y, _view) mod_pt = [x / @scale, y / @scale] set_dlg_position(mod_pt) # puts "onLButtonDown; flags = #{flags}" end #----------------------------------------------------------------------------------------# end # class #----------------------------------------------------------------------------------------# clk_dlg = ClicTool.new Sketchup.active_model.select_tool(clk_dlg) #----------------------------------------------------------------------------------------#
john
-
John,
Thanks. Good to know, even if it requires an extra library (Cliclick).
The web dialogs in SU is really an unfinished job. I wonder why, because this is actually very powerful. This problem of coordinates and the problem of controlling the focus are definitely to be addressed, but counting the number of releases of SU without any evolution in the Web Dialog area makes me think I may be the only one to care!
Fredo
-
@fredo6 said:
... even if it requires an extra library (Cliclick).
even my modified version of cliclick is only 99 KB and if all you want is mousePosition it could shrink a lot...
I believe you can use getMousePosition via ruby on a PC...
I also really like webDialogs and wish we had more control over them...
john
-
fredo,
I just compiled my own mouse_position bin script and it comes in at 19kb...I also played around with that script so the dialog never overhangs the viewport...
in reality it only needs to be run once per model with a corresponding click in SU to give you the variation between the 2 [ x, y] returns...
john
-
Hello fredo. For windows, you can use Win32 API or a C++ extension to get viewport origin in screen coordinates. It has been discussed here: http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=61867#p566233
It won't work on Mac, however, I guess you could try what driven suggested.
Advertisement