discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextField questions


From: Nicola Pero
Subject: Re: NSTextField questions
Date: Wed, 2 Oct 2002 11:59:41 +0100 (BST)

> > Dirk Lattermann wrote:
> > 
> > >The question is: how can I figure out when an NSTextField has just
> > >become the firstResponder? Is there a notification that is sent
> > >in this case?

There is no notification - the NSTextField becoming first responder is a
complex issue.  David was correct in saying that first responder is a
"volatile concept".

When you make an editable NSTextField first responder, the NSTextField
will react by setting up an editable NSTextView, put it over itself, and
making the NSTextView first responder in place of itself - all editing
will be channelled to the textview.

So, technically, the editable NSTextField is never first responder ... the
NSTextView is! :-)

Normally, the idea is that you - as a programmer - should not be
particularly concerned with what is first responder - the first responder
is just what could *potentially* be edited by the user at the moment -
this is supposed to be managed by the library for all standard controls.

If the user tries to _edit_ something, then you (/your delegate) are
immediately notified instead.

If you want a 'special' first responder behaviour, I'm afraid that is
considered an 'advanced' customization, which requires subclassing.

It seems that just overriding -becomeFirstReponder should be enough
though.


> > Maybe you could detail a bit more of what you want to do.
> 
> I'm currently hacking together an naive database GUI that is a little
> bit like a very lightweight version of oracle's forms runtime.
> Right now, it supports only text fields for items (I'm not quiet sure
> how to extend this to other NSControls, because I don't see how to
> "add member variables to NSControl and use functionalities of its
> subclasses", but that's another issue...).
> For several things, e.g. to move from one record in a block to another
> by pressing a "next record" button, I need to know the active block
> which is the block to which the active item (text field) belongs.
> The active item is the one which has the input focus, so I'm trying
> to be notified when the text field gets the input focus.
> 
> I don't know how to get this info from the window later when I need it,
> for example when a click on "next record" has occured, because then,
> the firstResponder has changed again.

I'm not sure I got all the description :-)

But you might likely need some custom stuff/subclass in here.

Delegation can't cover all possible customizations ... it covers all
`standard' ones.  But subclassing is quite fun actually, particularly if
you just have to override one or two methods. :-)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]