CPWindow windowShouldClose and CPAlert

22 مرّة مشاهدة
التخطي إلى أول رسالة غير مقروءة

david.ri...@enquora.com

غير مقروءة،
19‏/07‏/2016، 3:25:14 م19‏/7‏/2016
إلى Cappuccino & Objective-J
We have CPWindows displaying CRUD forms for selected data.
The detail views are currently non-modal.

On close of window, would like to:
  • Display CPAlert with three possible return states
    1. Close window and save changes to representedObject
    2. Close window and discard changes to representedObject
    3. Leave window open and continue editing
  • If changes to representedObject are to be saved, confirm that they have indeed been safely persisted (locally or remotely, depending on data) before closing window
The asynchronous behaviour of CPAlert doesn't seem to allow an obvious or clean to accomplish this - the windowShouldClose delegate method has finished executing before a return result is available from the alert.

It seems to require a combination of observers and a loop, or a chained sequence of CPOperations, using dependencies and passing state internally - but a clean approach isn't obvious to me yet.

We could make the detail window modal, requiring the user to switch from 'Show' to 'Edit' modes and vice-versa, and only allowing the window to be closed in a clean 'Show' state. This introduces extra keystrokes and mouse movement which I would like to avoid if possible.

Does anyone have suggestions on an architecture to support this?


Kerusan

غير مقروءة،
19‏/07‏/2016، 4:35:11 م19‏/7‏/2016
إلى objec...@googlegroups.com

Return NO from windowShouldClose: will halt the closing. Your alert can then finish and if window should then close send closeWindow and return YES in windowShouldClose:

I think that will work.

--kerusan


Skickat från min iPhone
--
You received this message because you are subscribed to the Google Groups "Cappuccino & Objective-J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectivej+...@googlegroups.com.
To post to this group, send email to objec...@googlegroups.com.
Visit this group at https://groups.google.com/group/objectivej.
For more options, visit https://groups.google.com/d/optout.

david.ri...@enquora.com

غير مقروءة،
20‏/07‏/2016، 1:02:21 م20‏/7‏/2016
إلى Cappuccino & Objective-J


On Tuesday, July 19, 2016 at 2:35:11 PM UTC-6, kerusan wrote:

Return NO from windowShouldClose: will halt the closing. Your alert can then finish and if window should then close send closeWindow and return YES in windowShouldClose:

I think that will work.

Yes, that works. I had assumed that [window close] would invoke windowShouldClose: again, requiring an ugly state management mechanism.
It actually by-passes windowShouldClose: (use [window performClose:] to invoke windowShouldClose:)

Thanks. 
الرد على الكل
رد على الكاتب
إعادة توجيه
0 رسالة جديدة