More weekend refactoring and I’d like to get rid of a deprecation on a call to GetSheetWindowParent since it uses the Carbon lib instead of Cocoa. I’ve hit the Apple headerdocs, but I’m either using the wrong search term or they don’t have it documented.
Does anyone have a Cocoa replacement that allows us to check a window to see if a sheet is attached?
Actually, I’m using that function to determine is a Window ‘w’ has a sheetwindow attached after the fact. It may be that further refactoring work may obviate the need since I’m now using a better mechanism for tracking my dialogs, but the requirement still exists for the moment.
The reason behind needing this is that the sheet can sometimes display on the wrong window if the user has clicked at JUST that right moment…
Also, a sheet window has exactly the same top as the parent window.
Using these two values, you can ascertain if a particular sheet window is actually child.
Function isChild(extends sheet as window, parent as window) As boolean
if sheet.Left = parent.Left+(parent.width-sheet.width)/2 and _
sheet.top = parent.top then
return true
else
return false
end if
End Function
msgbox str(self.ischild(window1))
You can refine that if your sheet displays at a different left position, or if you display a ModalDialog.