On Wed, May 14, 2014 at 11:10 AM, Staffan Tylen <staffan.tylen@gmail.com> wrote:
...
 
Then a question: why is onMove not called when moving the window? Is it what I think it is, that sheet is a dialog control, not a dialog window?

That's on the right track, but not exactly correct.  The PropertySheetDialog is a dialog that  belongs to the operating system.  It is not directly created by ooDialog.  Event notifications are sent to the operating system, not sent to the ooDialog framework.


The second question is: it seems like the leaving method is the only method getting called when sheet is closed. ok, cancel, and validate don't get called.

That's correct.  ok, and cancel are invoked by intercepting the ok or cacel button clicks.  The ok and cancel buttons belong to the PropertySheetDialog, which isn't managed by the ooDialog framework. validate() is actually invoked from the ok() method, which is never invoked in this case.
 
And leaving doesn't allow one to save the current state in a database, probably because of thread issues. So how can I save the current position of sheet when it's closed? I tried by using the omMove method to save it whenever sheet was moved, but as it doesn't get called it was no solution.

Walking in circles here, is there a solution?

Yes there is a solution.  You need to intercept one of the notifications that are sent to the property sheet pages.  You actually need to intercept several for a complete solution.

It's a little more complicated in a PropertySheetDialog because you need to intercept the queryCancel() and the killActive() notifications.  A little reading of the methods in the doc should help you understand why.

From your example:

::class page1 subclass userpspdialog inherit resizingadmin

::method queryCancel unguarded
  use arg propSheet
  self~recordPos(propSheet)
  return .true

::method killActive unguarded
  use arg propSheet
  self~recordPos(propSheet)
  return .true

::method recordPos private unguarded
  use strict arg propSheet
  pos = propSheet~windowRect

  -- Record window position
  say 'Window postion / size:' pos

Which produces when run:

C:\work.ooRexx\staffan\propSheetPos>test
Window postion / size: a Rect (25, 25, 402, 481)

Now, your example was very simple.  You need to think about a few things in a more complicated program.  queryCancel() is sent to each page of the property sheet when the user cancels and you need to return .false to prevent the cancellation.  So that works fine 

killActive() is sent to a page when the user moves to another page, or when the user presses the ok button.  You return .false to prevent the user leaving the page.  So, if you have a number of pages, the method gets invoked when the dialog is not closing.  But, recording the position will still happen a lot fewer times, on average, then recording the positions each time the user moves the dialog.

However, this statement of yours:

And leaving doesn't allow one to save the current state in a database, probably because of thread issues. 

doesn't make any sense to me. The leaving() method is the natural place to have your code:

::method leaving
  pos = self~propSheet~windowRect
  say 'PropSheet page leaving.  Window postion / size:' pos

which gives:

C:\work.ooRexx\staffan\propSheetPos>test
PropSheet page leaving.  Window postion / size: a Rect (50, 50, 427, 506)

There is no reason I can see why that won't work

--
Mark Miesfeld