Commits

Brandon Walkin  committed 521771d

Sheet controller - API change: delegate method now gets passed the appropriate button instead of the window

  • Participants
  • Parent commits 0d775e3

Comments (0)

Files changed (4)

File BWControllersLibrary.nib/designable.nib

 <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
 	<data>
 		<int key="IBDocument.SystemTarget">1050</int>
-		<string key="IBDocument.SystemVersion">9E17</string>
+		<string key="IBDocument.SystemVersion">9G55</string>
 		<string key="IBDocument.InterfaceBuilderVersion">677</string>
-		<string key="IBDocument.AppKitVersion">949.33</string>
-		<string key="IBDocument.HIToolboxVersion">352.00</string>
+		<string key="IBDocument.AppKitVersion">949.43</string>
+		<string key="IBDocument.HIToolboxVersion">353.00</string>
 		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
 			<bool key="EncodedWithXMLCoder">YES</bool>
 			<integer value="7"/>
 						<string key="identifier">FB2E7CB9-EA98-4C6F-B4EE-7CFA4E1599D2</string>
 						<string key="briefDescription">Controller object for loading and dismissing sheets.</string>
 						<object class="NSAttributedString" key="fullDescription">
-							<string key="NSString">Controller object for loading and dismissing sheets. To use, connect its outlets and actions. Optionally, you can connect the delegate outlet if you want to execute code when an action occurs on the sheet. The delegate should implement the method -(BOOL)shouldCloseSheet:(NSWindow *)sheet.</string>
+							<string key="NSString">Controller object for loading and dismissing sheets. To use, connect its outlets and actions. Optionally, you can connect the delegate outlet if you want to execute code when an action occurs on the sheet. The delegate should implement the method -(BOOL)shouldCloseSheet:(id)sender.</string>
 							<object class="NSMutableArray" key="NSAttributes">
 								<bool key="EncodedWithXMLCoder">YES</bool>
 								<object class="NSDictionary">
 								</object>
 							</object>
 							<object class="NSMutableData" key="NSAttributeInfo">
-								<bytes key="NS.bytes">9wEAAgEEAhMBCAMDAQYEA</bytes>
+								<bytes key="NS.bytes">9wEAAgEEAhUBBwMBBA</bytes>
 							</object>
 						</object>
 						<string key="initialCategoryPath">Controllers</string>
 						<object class="NSMutableArray" key="dict.sortedKeys">
 							<bool key="EncodedWithXMLCoder">YES</bool>
 							<string>closeSheet:</string>
-							<string>closeSheetAndMessageDelegate:</string>
+							<string>messageDelegateAndCloseSheet:</string>
 							<string>openSheet:</string>
 						</object>
 						<object class="NSMutableArray" key="dict.values">

File BWControllersLibrary.nib/keyedobjects.nib

Binary file modified.

File BWSheetController.h

 - (IBAction)closeSheet:(id)sender;
 - (IBAction)messageDelegateAndCloseSheet:(id)sender;
 
+// The optional delegate should implement the method:
+// - (BOOL)shouldCloseSheet:(id)sender
+// Return YES if you want the sheet to close after the button click, NO if it shouldn't close. The sender
+// object is the button that requested the close. This is helpful because in the event that there are multiple buttons
+// hooked up to the messageDelegateAndCloseSheet: method, you can distinguish which button called the method. 
+
 @end

File BWSheetController.m

 	[sheet setAlphaValue:0];
 	[sheet performSelector:@selector(orderOut:) withObject:nil afterDelay:0];
 	
-	// If the sheet has a toolbar, make sure it isn't movable (private API)
-	[sheet setMovable:NO];
+	// If the sheet has a toolbar or a bottom bar, make sure those elements can't move the window (private API)
+	if ([sheet respondsToSelector:@selector(setMovable:)])
+		[sheet setMovable:NO];
 }
 
 - (id)initWithCoder:(NSCoder *)decoder;
 {
 	if (delegate != nil && [delegate respondsToSelector:@selector(shouldCloseSheet:)])
 	{	
-		if ([delegate performSelector:@selector(shouldCloseSheet:) withObject:sheet])	
+		if ([delegate performSelector:@selector(shouldCloseSheet:) withObject:sender])	
 			[self closeSheet:self];
 	}
 	else