I've been working through this a bit more.  To get bindings to work, I added 
the following to my custom textfield:

        if (!bindingsDict) {
                self.stringValue = newStringValue;
        }
        
        if (bindingsDict) {
                NSString *boundObject = [bindingsDict 
valueForKey:@"NSObservedObject"];
                NSString *boundKeyPath = [bindingsDict 
valueForKey:@"NSObservedKeyPath"];
                
                [boundObject setValue:newStringValue forKeyPath:boundKeyPath];
        }
        
        [self.window endEditingFor:self];

There's a lot more to mimicking the look of iCal / AddressBook editing, though. 
 Both apps use attributed strings, and the text fields and borderless windows 
are sized to fit the attributed string (or the attributed placeholder string, 
if no string has been entered).  If the string being entered will exceed the 
width of the window that popped up, the window will begin to grow to 
accommodate the additional letters, and will push text in the main window to 
the side to make room once the enter button is pressed.

AddressBook-style editing with the plus and minus buttons to add or remove 
fields is also not insignificant.

On Jan 13, 2010, at 2:23 PM, Josh Abernathy wrote:

> This sounds more like a CoreData or general controller problem than anything 
> specific to iCal-style text fields. You might want to create a new thread for 
> this.
> 
> 
> On Jan 13, 2010, at 11:44 AM, Brad Gibbs wrote:
> 
>> I'm trying to implement this.
>> 
>> I created a custom NSTextField subclass, called ICNTextField.  When an 
>> ICNTextField instance receives a mouseDown event, it initializes a custom 
>> NSWindow subclass with a borderless window mask.  In the window subclass, 
>> I've overridden -canBecomeKeyWindow: so that it always returns yes.  
>> 
>> When ICNTextField receives the controlTextDidEndEditing notification, it 
>> takes the string value from the text field in the borderless window and 
>> displays it properly, but the Core Data attribute to which the original text 
>> field is bound does not update its value.
>> 
>> I've looked into endEditing and endEditing:, nextKeyView and various forms 
>> of commit, but can't seem to find a way to get the bindings to recognize the 
>> new string value.  
>> 
>> I'd like to do this in a generic fashion, so I can make any text field an 
>> ICNTextField and know that its bound attributes will be updated without 
>> having to write additional code for each text field.  Any help would be 
>> appreciated. 
>> 
>> 
>> On Jan 10, 2010, at 2:54 PM, Josh Abernathy wrote:
>> 
>>> If you're asking about the shadow, create a child window and move them to 
>>> that when they're editing.
>>> 
>>> 
>>> On Jan 10, 2010, at 11:56 AM, Seth Willits wrote:
>>> 
>>>> On Jan 10, 2010, at 11:49 AM, Ulai Beekam wrote:
>>>> 
>>>>> Go into iCal (in Snow Leopard) and create a new event and and then click> 
>>>>> outside that event. Then double-click on that event and hit the "Edit" 
>>>>> button.
>>>>> 
>>>>> In the window you see, you have some neat looking text fields that show> 
>>>>> only text when not in focus but show you a white background with a 
>>>>> shadow> effect when in edit mode.
>>>>> 
>>>>> How can I make such text fields? Does anyone happen to have them 
>>>>> ready-made?
>>>> 
>>>> They're just text fields. Change the background color, turn off the 
>>>> border, and make them read-only when not in edit mode. 
>>>> 
>>>> 
>>>> --
>>>> Seth Willits
>>>> 
>>>> 
>>>> 
>>>> _______________________________________________
>>>> 
>>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>>> 
>>>> 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:
>>>> http://lists.apple.com/mailman/options/cocoa-dev/joshaber%40gmail.com
>>>> 
>>>> This email sent to josha...@gmail.com
>>> 
>>> _______________________________________________
>>> 
>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>> 
>>> 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:
>>> http://lists.apple.com/mailman/options/cocoa-dev/bradgibbs%40mac.com
>>> 
>>> This email sent to bradgi...@mac.com
>> 
>> _______________________________________________
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> 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:
>> http://lists.apple.com/mailman/options/cocoa-dev/joshaber%40gmail.com
>> 
>> This email sent to josha...@gmail.com
> 

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to