SH Development
2016-12-11 06:28:43 UTC
I’ve been going around and around with this for a while now this evening.
I have a very simple program that writes to a prefs file with the main window’s placement, top, left. This happens both when the window is closed AND when it is moved. Prefs are saved on either event.
The prefs file correctly shows the position I have dragged the window to on any of the screens. However, when I relaunch the application, it always resets the left to a value of 10 and changes it in the prefs file.
In trying different settings for the window in the IDE, I have found that changing the placement behavior affects the problem. When set to “Default”, it always reverts to a left value of 10. When set to "Main Screen", it always jumps back to a left value of 1422, basically centered on my gi-normous 34” Dell monitor.
Is there a way to NOT use any kind of default behavior and simply position the window where I set it? Code follows:
Sub Open()
// Initialize the preferences handler and check for an existing prefs file. PreferencesModule.Initialize(“Test Program")
If Not Preferences.Load then
Preferences.wTop=10 // Main window top coordinate.
Preferences.wLeft=50 // Main window left coordinate.
If Not Preferences.Save Then
MsgBox("Could not save preferences.”)
End If
// This will create the folder ~/Library/Application Support/Test Program if it doesn't already exist.
// Creates the default preferences.
End if
mainwindow.Show
End Sub
Sub Close()
Preferences.wTop=self.top
Preferences.wLeft=self.left
If Not Preferences.Save Then
MsgBox("Could not save preferences.”)
End If
End Sub
Sub Moved()
Preferences.wTop=self.top
Preferences.wLeft=self.left
If Not Preferences.Save Then
MsgBox("Could not save preferences.”)
End If
End Sub
Sub Open()
self.top=Preferences.wTop
self.left=Preferences.wLeft
End Sub
I am using the preferences module from Paul Lefebvre as posted on the Xojo developer site. Thoughts?
Jeff J.
_______________________________________________
Xojo forum:
https://forum.xojo.co
I have a very simple program that writes to a prefs file with the main window’s placement, top, left. This happens both when the window is closed AND when it is moved. Prefs are saved on either event.
The prefs file correctly shows the position I have dragged the window to on any of the screens. However, when I relaunch the application, it always resets the left to a value of 10 and changes it in the prefs file.
In trying different settings for the window in the IDE, I have found that changing the placement behavior affects the problem. When set to “Default”, it always reverts to a left value of 10. When set to "Main Screen", it always jumps back to a left value of 1422, basically centered on my gi-normous 34” Dell monitor.
Is there a way to NOT use any kind of default behavior and simply position the window where I set it? Code follows:
Sub Open()
// Initialize the preferences handler and check for an existing prefs file. PreferencesModule.Initialize(“Test Program")
If Not Preferences.Load then
Preferences.wTop=10 // Main window top coordinate.
Preferences.wLeft=50 // Main window left coordinate.
If Not Preferences.Save Then
MsgBox("Could not save preferences.”)
End If
// This will create the folder ~/Library/Application Support/Test Program if it doesn't already exist.
// Creates the default preferences.
End if
mainwindow.Show
End Sub
Sub Close()
Preferences.wTop=self.top
Preferences.wLeft=self.left
If Not Preferences.Save Then
MsgBox("Could not save preferences.”)
End If
End Sub
Sub Moved()
Preferences.wTop=self.top
Preferences.wLeft=self.left
If Not Preferences.Save Then
MsgBox("Could not save preferences.”)
End If
End Sub
Sub Open()
self.top=Preferences.wTop
self.left=Preferences.wLeft
End Sub
I am using the preferences module from Paul Lefebvre as posted on the Xojo developer site. Thoughts?
Jeff J.
_______________________________________________
Xojo forum:
https://forum.xojo.co