Ask a Question related to Mac Programming, Design and Development.
-
None #1
Cocoa, changing window close behavior?
Is there an easy way to change the window closing behavior in Cocoa?
I'd like to have a slightly unorthodox behavior, in which the main
document window has finder-like icons that represent individual data
documents. Double clicking an icon opens one (or more) views of the
document data. I'd like to set it so that closing the data view windows
does not send a closedocument message to the data documents, but just
hides the data window. Instead, either closing the main icon window
would send individually closedocument messages to all of the data
documents, or else highlighting a single icon and deleting it (for
example) would send the same message to just that one data document.
Is there an override to do this?
thanks,
Rick
None Guest
-
Modeless dialog parent window in Cocoa
I'm trying to use Cocoa dialog in my plug-in. It opens OK and works properly except that it can "hide" behind active doc's window. I can't work out... -
Close Window Behavior
My problem window close is retated to behaviours. I will describe: 1 - I have imported from photoshop the layout. This layout displays a remote... -
close my project that is in a browser window (close this window)
How can I do this with a button? What do I have to put into button? -
Fixing Tab Order in Cocoa Window
I am a Cocoa Newbie who comes from VB. In VB, you can choose from properties whether I have a "TabStop" on a particular command button, option... -
multiple document and window types in cocoa
In <210720030631331455%none@none.com> None wrote: Use the existing document framework. Let the AppKit do the work. You don't need to store... -
John C. Randolph #2
Re: Cocoa, changing window close behavior?
None wrote:
Implement -windowWillClose in the window's delegate method. Do whatever>
> Is there an easy way to change the window closing behavior in Cocoa?
> I'd like to have a slightly unorthodox behavior, in which the main
> document window has finder-like icons that represent individual data
> documents. Double clicking an icon opens one (or more) views of the
> document data. I'd like to set it so that closing the data view windows
> does not send a closedocument message to the data documents, but just
> hides the data window. Instead, either closing the main icon window
> would send individually closedocument messages to all of the data
> documents, or else highlighting a single icon and deleting it (for
> example) would send the same message to just that one data document.
>
> Is there an override to do this?
you want in that method, and then return YES if you still want the
window to close, and NO if you don't.
-jcr
John C. Randolph Guest
-
None #3
Re: Cocoa, changing window close behavior?
In article <3F3F5DD4.99C027D8@nospam.idiom.com>, John C. Randolph
<jcr@nospam.idiom.com> wrote:
Thanks for the suggestion. That almost works perfectly. I actually used>> > Is there an override to do this?
> Implement -windowWillClose in the window's delegate method. Do whatever
> you want in that method, and then return YES if you still want the
> window to close, and NO if you don't.
>
> -jcr
windowShouldClose, since windowWillClose is called later. I overrode it
as:
- (BOOL)windowShouldClose:(id)sender
{
[sender orderOut:self];
return NO;
}
and the window nicely disappears, but still sticks around. The only
remaining problem is if the window contents have changed, before either
windowShouldClose or windowWillClose get called, the "Do you want to
save changes" dialog appears. This really disrupts the work flow (for
the user), and should not be asked until the document really is about
to close. Do you know how I can block that dialog from showing up? I
was thinking about messing with the setWindowIsEdited thing all the
time to make the system think the window contents have not really
changed, but somehow that seems a bit risky in case I forget to set it
back...
Thanks very much
None Guest
-
Michael Ash #4
Re: Cocoa, changing window close behavior?
In article <170820030829201894%none@none.com>, None <none@none.com>
wrote:
Hold down the shift key and hit the minimize button in any window of any> Weird, Is this a bug in Cocoa? I tried an alternative strategy, in
> which instead of using the "close" behavior, I just use the minimize
> window function to unclutter the screen. Clicking the window minimize
> button of course works as usual, and the window genies down in about 1
> second (on a 400 MHz Pismo). I made a new menu command (shift-apple-W)
> with the command to firstResponder to performMiniturize. When I run the
> application (either from project builder, or on its own), the menu
> command works, but it take over five seconds for the window to shrink
> down into the dock!! Has anyone else seen this sort of strange
> behavior before?
app, you'll see the same behavior. It's some kind of demonstration
thing. Use a key combo that doesn't involve shift.
Michael Ash Guest
-
Paul Mitchum #5
Re: Cocoa, changing window close behavior?
None <none@none.com> wrote:
[..]> I'd like to have a slightly unorthodox behavior, in which the main
> document window has finder-like icons that represent individual data
> documents. Double clicking an icon opens one (or more) views of the
> document data. [..]
To change the behavior of the 'do you want to save?' process for your> Thanks for the suggestion. That almost works perfectly. I actually used
> windowShouldClose, since windowWillClose is called later. I overrode it
> as:
>
> - (BOOL)windowShouldClose:(id)sender
> {
> [sender orderOut:self];
> return NO;
> }
>
> and the window nicely disappears, but still sticks around. The only
> remaining problem is if the window contents have changed, before either
> windowShouldClose or windowWillClose get called, the "Do you want to save
> changes" dialog appears. This really disrupts the work flow (for the
> user), and should not be asked until the document really is about to
> close. Do you know how I can block that dialog from showing up? I was
> thinking about messing with the setWindowIsEdited thing all the time to
> make the system think the window contents have not really changed, but
> somehow that seems a bit risky in case I forget to set it back...
document, you have to override
shouldCloseWindowController:delegate:shouldCloseSe lector:contextInfo
and/or it's matching canCloseDocumentWithDelegate:etc:etc method, both
in NSDocument. They're pretty confusing, compared to the rest of the
document system. Helpful sample code here:
<http://makeashorterlink.com/?H19D23D95>
If your document class does what it should, and creates a separate
windowcontroller for each sub-view, then you can use the first argument
of shouldCloseWindowController to figure out if the user is closing the
main document window, or one of the sub-view windows. You can allow
sub-views to close regardless, and you can allow the default behavior
for the main window.
If you're making a new document object for each subview, then you get to
do the same thing with canCloseDocumentWithDelegate:etc:etc:.
HTH.
Paul Mitchum Guest
-
Doc O'Leary #6
Re: Cocoa, changing window close behavior?
In article <mail-5F7E48.10062817082003@localhost>,
Michael Ash <mail@mikeash.com> wrote:
The standard one being command+M, which is already in the Window menu of> Hold down the shift key and hit the minimize button in any window of any
> app, you'll see the same behavior. It's some kind of demonstration
> thing. Use a key combo that doesn't involve shift.
a Cocoa app.
Doc O'Leary Guest
-
None #7
Re: Cocoa, changing window close behavior?
In article <1fzu61p.9hnpn5ospglvN%usenet@mile23.com>, Paul Mitchum
<usenet@mile23.com> wrote:
Thanks, that seems to be exactly what I want to override. As you say,> To change the behavior of the 'do you want to save?' process for your
> document, you have to override
> shouldCloseWindowController:delegate:shouldCloseSe lector:contextInfo
> and/or it's matching canCloseDocumentWithDelegate:etc:etc method, both
> in NSDocument. They're pretty confusing, compared to the rest of the
> document system. Helpful sample code here:
> <http://makeashorterlink.com/?H19D23D95>
>
> If your document class does what it should, and creates a separate
> windowcontroller for each sub-view, then you can use the first argument
> of shouldCloseWindowController to figure out if the user is closing the
> main document window, or one of the sub-view windows. You can allow
> sub-views to close regardless, and you can allow the default behavior
> for the main window.
>
> If you're making a new document object for each subview, then you get to
> do the same thing with canCloseDocumentWithDelegate:etc:etc:.
>
> HTH.
it's a bit more complicated than the "user servicible" functions, and I
can't seem to get it to compile. When I put in the:
void (*callback)(id, SEL, NSDocument *, BOOL, void *) =
(void (*)(id, SEL, NSDocument *, BOOL, void *))objc_msgSend;
part, project builder complains that "objc_msgSend is undeclared"
The documentation on objc_msgSend does not clarify what header file
should be included, and the usage looks different. Do you know what I
should add to be able to use it in this context?
thanks very much for your help
None Guest
-
Michael Ash #8
Re: Cocoa, changing window close behavior?
In article <200820032221511238%none@none.com>, None <none@none.com>
wrote:
[Foobar:~] mikeash% grep -r objc_msgSend /usr/include> part, project builder complains that "objc_msgSend is undeclared"
> The documentation on objc_msgSend does not clarify what header file
> should be included, and the usage looks different. Do you know what I
> should add to be able to use it in this context?
[snip]
/usr/include/objc/objc-runtime.h:OBJC_EXPORT id objc_msgSend(id self,
SEL op, ...);
[snip]
Michael Ash Guest



Reply With Quote

