-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SplitView autosaveName has no effect #62
Comments
I see that the pane setting end up in the prefs file, but somehow they're being ignored when setting up the NSSplitView. |
I found a workaround at https://stackoverflow.com/questions/16587058/nssplitview-auto-saving-divider-positions-doesnt-work-with-auto-layout-enable But it still doesn't work. By printing the frame info that is being fetched from the defaults I see that even though the correct frames are initially being stored, we're getting the default values anyway. Something in the way vanilla sets up the NSSplitView causes the defaults to be rewritten to their default values. from AppKit import NSUserDefaults
from vanilla import *
def restoreAutosavedPositions(self):
# Yes, I know my Autosave Name; but I won't necessarily restore myself automatically.
key = "NSSplitView Subview Frames %s" % self.autosaveName()
subviewFrames = NSUserDefaults.standardUserDefaults().valueForKey_(key)
print(subviewFrames)
# the last frame is skipped because I have one less divider than I have frames
for i in range(len(subviewFrames) - 1):
# this is the saved frame data - it's an NSString
frameString = subviewFrames[i]
components = frameString.split(", ")
# only one component from the string is needed to set the position
# if I'm vertical the third component is the frame width
if self.isVertical():
position = components[2]
# if I'm horizontal the fourth component is the frame height
else:
position = components[3]
self.setPosition_ofDividerAtIndex_(float(position), i)
leftPane = List((0, 0, 0, 0), range(10))
rightPane = List((0, 0, 0, 0), range(10, 30))
paneDescriptors = [
dict(view=leftPane, identifier="pane1"),
dict(view=rightPane, identifier="pane2"),
]
w = Window((500, 300), "SplitViewTest")
w.splitView = SplitView((0, 0, -0, -0), paneDescriptors, autosaveName="myautosavename")
restoreAutosavedPositions(w.splitView._nsObject)
w.open() |
Is this the way I should use that? I was expecting the panes to be restored to their saved positions when running this, but they go back to their 50% default. I'm on 10.10 if that matters.
The text was updated successfully, but these errors were encountered: