Re. Cascading windows in document architectures
Re. Cascading windows in document architectures
- Subject: Re. Cascading windows in document architectures
- From: perego <email@hidden>
- Date: Mon, 3 Mar 2008 12:40:06 +0100
Hi!
Finally, I found the time to investigate the problem. The issue seems to
be actually connected with the fact that a window is already displayed
when [aNSWindow cascadeTopLeftFromPoint:] is called as a result of
[aNSWindowController window] call. Here follows the debugging trace
generated by the opening of a new text document in my app. When
cascadeTopLeft... is called the window is not displayed and the
cascading
mechanism works well.
#0 0x91d34838 in -[NSWindow cascadeTopLeftFromPoint:]
#1 0x91d1b9c4 in -[NSWindowController _windowDidLoad]
#2 0x91cc3e48 in -[NSWindowController window]
#3 0x91cc3d2c in -[NSWindowController showWindow:]
#4 0x0002ad40 in -[MyTextWController showWindow:] at
MyTextWController.m:33
#5 0x91cc3c68 in -[NSDocument showWindows]
#6 0x920a1e7c in -[NSDocumentController(NSDeprecated)
openUntitledDocumentOfType:display:]
#7 0x00005980 in -[MyDocumentController newDocument:] at
MyDocumentController.m:64
#8 0x91d7a3bc in -[NSApplication sendAction:to:from:]
#9 0x91e15abc in -[NSMenu performActionForItemAtIndex:]
#10 0x91e157ec in -[NSCarbonMenuImpl
performActionWithHighlightingForItemAtIndex:]
#11 0x91df6fac in AppKitMenuEventHandler
#12 0x9543cf6c in DispatchEventToHandlers
#13 0x9543c104 in SendEventToEventTargetInternal
#14 0x954590e4 in SendEventToEventTarget
#15 0x9548efd4 in SendHICommandEvent
#16 0x954b583c in SendMenuItemSelectedEvent
#17 0x954b5728 in FinishMenuSelection
#18 0x954924e8 in MenuSelectCore
#19 0x95491efc in _HandleMenuSelection2
#20 0x91d48dec in _NSHandleCarbonMenuEvent
#21 0x91cbe858 in _DPSNextEvent
#22 0x91cbdd88 in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:]
#23 0x91cb7a44 in -[NSApplication run]
#24 0x91c88448 in NSApplicationMain
#25 0x000025b8 in main at main.m:5
#26 0x00002500 in _start
#27 0x00002204 in start
I investigated the process for my other type of document and I noticed
that the window was
already shown at cascadeTopLeft... time. The culprit was a superfluous
"makeKeyAndOrderFront" call
within the "windowDidLoad" method of my NSWindowController subclass, a
remnant of
a previous organization of my app.
The key to solve my problem was putting a break on [NSWindow
cascadeTopLeftFromPoint:]
and verifying that the window was already displayed. After that, I had
to follow the sequence
and find where exactly the window came on screen.
Andrea Perego
Univ. of Florence - Phys. Dept.
On Mon, Feb 25, 2008 at 12:19 PM, Jacob Lukas
<email@hidden> wrote:
I had this problem as well. The fix for me was to not show the window
during awakeFromNib, but rather let the window be cascaded and shown
automatically. It seems that if the window is already visible before
it has been cascaded, the cascading step is skipped.
Similarly, I have found that things work better if you ensure "visible
at launch" is unchecked for your document's window.
NSWindowController will take care of displaying the window for you if
it's appropriate, and seems to do a bit of thinking about what it
does.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden