Re: Modal Window for NSTextField
Re: Modal Window for NSTextField
- Subject: Re: Modal Window for NSTextField
- From: Fritz Anderson <email@hidden>
- Date: Tue, 03 Jan 2012 08:58:33 -0600
On 3 Jan 2012, at 3:29 AM, Dany Golubitsky wrote:
> I am sorry, I am new to Cocoa and some things that looks completely obvious to you are completely unknown to me.
> (controlTextDidEndEditing: notification) - What is this function, where should it be implemented, who should call it?
It is a delegate method of NSControl. (Read up on the "delegate" design pattern for the concept.) You must make some object a delegate of each field you want to respond to; the object can then respond to the current value of the field. Use the firstResponder method of the enclosing window to get a pointer to the field. Searching the documentation will tell you more. (Perhaps you've done that, and don't want to believe what you're seeing.)
> How need I start the TextField?
Send it to the window as the parameter for the window's -makeFirstResponder: method.
> For my code I need to call opening function, wait for it to open, get text from user and return. Meaning:
>
> {
> Block 1
> }
> Calling for TextField and waiting for return value.
> {
> Block 2
> }
>
> Getting return value in some other place is not an option.
Running a text field modally is not a favored option. Few developers do it, because it's easier to defer processing till their did-end-editing method is called. It might be possible to lash something together with a borderless window, but this is a framework: _It_ calls _you_. If you want to program for the Macintosh, you really have to be able to design for asynchrony. Fighting the framework is a losing proposition.
— F
_______________________________________________
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