Post some code. --
You received this message because you are subscribed to the Google Groups "SketchUp Ruby API" group.
To post to this group, send email to sketch...@googlegroups.com.
To unsubscribe from this group, send email to sketchupruby...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sketchupruby?hl=en.
UI::WebDialog.new("foo", true, "testkey").show()
you are creating a new instance of a web dialog, which wipes out the old one.
However, if you code this:
u = UI::WebDialog.new("foo", true, "testkey")
u.show()
move the dialog
close the dialog
u.show()
it will show up where you left it.
what about using x,y,width, height arguments?
or:
what about making calls to set_size() and set_postion() before you
call show() ?
also when you instance a WebDialog object, they may not get GC'd
during the session. I remember TIG or AdamB writing about this.
What happens if you close SU, reopen it, and open a new "foo" dialog ?
Coding it right, it works for me just fine.Recognize what you are doing. Each time you issueUI::WebDialog.new("foo", true, "testkey").show()
you are creating a new instance of a web dialog, which wipes out the old one.
However, if you code this:
u = UI::WebDialog.new("foo", true, "testkey")
u.show()
move the dialog
close the dialog
u.show()
it will show up where you left it.
On Jan 14, 6:00 am, Jonathan Winterflood wrote:Do you see this behaviour with 7.x and 8.x, or is this a new bug ?
>
> On MacOS however, we're back to square one when we reboot SketchUP, whereas
> Windows/Wine stores the position against the key, and reopens the dialog in
> the correct place.
I will say that the UI::WebDialog.new() method is "cranky" when it
comes to processing arguments... if you put nil as the pref_key arg,
the method stops processing the remaining args. We discussed this in
the API topic over at SCF.
This is why I asked if you specified all arguments... the argument
processing for that method needs an overhaul !!
Your other option is to use the hash list as the argument, and try out
the 9th argument which has hashkey "mac_only_use_nswindow" (boolean
value.) Note that processing of a hash is also cranky... it doesn't
work correctly if string keys are used (at least on SU 7.x,) ... so
use symbol keys.
keys = {
:dialog_title => title,
:scrollable => false,
:preferences_key => 'MyDialog',
:height => 300,
:width => 400,
:left => 200,
:top => 200,
:resizable => true,
:mac_only_use_nswindow => true}
@dialog = UI::WebDialog.new(keys)
ThomThom has started a topic at SCF to discuss this... seems we have
problems on PC as well, when using a hash (7.1 and 8.x,) but using
just args works.
http://forums.sketchucation.com/viewtopic.php?f=180&t=34216
By the way...
I think that there should only be one dialog instance using a specific
key.
On PC they are prepended with "WebDialog_" in the registry.
Dont know if it's the same on Mac for plist files.
The DC Extension adds a few methods to the UI::WebDialog class. (**But
DCs must be enabled**)
last_height()
last_height()=
last_width()
last_width()=
So at least for size, you can use the getters within your
set_on_close() method to save the dialog size to your plugin's
defaults, and restore them thru the new() args, when the plugin is
used again.
For position... perhaps thru Javascript, maybe the window object have
a method / function to get position, then you could send it to ruby
via a calback, and again save to your plugins defaults.
x = window.screenLeft
y = window.screenTop
These may be IE only, as the bottom of the MSDN page says "There is no
public standard that applies to this property."
~
Myself.. I am 99% ready to abandon any interaction using
write_defaults() and read_defaults(), and just start using a settings
hash, then write it out to a file (in the plugin's subfolder,) using
hash.inspect(). To use the file, just read it into a String, and
eval() it back into a hash var:
# writes it out
sfile = File.new("subdir/mypluginsettings.txt",'w')
sfile.write( settings_hash.inspect )
sfile.close
# brings it in:
sfile = IO.readlines("subdir/mypluginsettings.txt")[0]
settings_hash = eval( sfile.chomp )
On Jan 15, 10:00 pm, Jonathan Winterflood wrote:
> On Sun, Jan 16, 2011 at 02:32, Dan Rathbun wrote:
>
> > Myself.. I am 99% ready to ... just start using a settings
> > hash, then write it out to a file ...
>
> Nice, and easier for any more than a few bits of data.
>
> The downside is that it's not user-specific any more.
> In my case I only have one string to save (actually aNo problem on the User!
> legacy code that is a base64 of the data!)
Mac : user = ENV['User']
Win : user = ENV['USERNAME']
The beauty of the inspect() method is that it properly walks complex
nested structures and outputs a string that can be re-eval'd back into
that same structure.
This means Arrays with nested arrays and /or hashes, or a Hash, with
nested arrays or hashes. It's similar to a JSON string.
Anyway... you can have a Settings hash, with User Keys pointing at a
single value (if you wish,) OR pointing at a nested array or nested
hash.
And BTW.. (offtopic,) this same feature can be used to easily store
and retrieve, complex data structures into/outof Attribute Dictionary
values.
~
~