Re: Following focus and scrolling controls into view
Re: Following focus and scrolling controls into view
- Subject: Re: Following focus and scrolling controls into view
- From: Mason Mark <email@hidden>
- Date: Sun, 16 Sep 2001 15:38:39 -0700
--On Sunday, September 16, 2001 11:13 AM +0200 Ondra Cada <email@hidden>
wrote:
Mason,
Mason Mark (MM) wrote at Sat, 15 Sep 2001 21:44:48 -0700:
MM> An app I am working on has a window containing a scrollable view
MM> containing many controls (buttons, text fields, text
views...functionally MM> similar to a typical web form that extends down
beyond the window's MM> edge).
MM>
MM> As the user tabs between text fields and controls, they may tab to an
MM> offscreen control. In this case, I would like to scroll the enclosing
MM> view down programatically, so that the focused control is visible in
the MM> document window.
MM>
MM> I think there must be a mechanism by which my app can "notice" when a
new MM> control or view gets the focus, since this is standard behavior
for so MM> many apps. Can anybody point me in the right direction?
As for the "standard behavior for so many apps", so far I've never needed
to know _outside_ and object whether it became (or resigned) first
responder.
Well, perhaps there are not "so many" apps that have a window full of
controls that extends beyond the visible area of the window, but OmniWeb,
MSIE, iCab, etc all do. It seems to me that almost any app that has
controls that the user can tab between will want to scroll those controls
into view when the user tabs to them--otherwise the user would be "typing
blind" and could easily make an error.
Anyway, unless I missed something, there is no standard
notification of that; you'll have to check yourself (either by posing
your own NSResponder subclass as NSResponder, which would post a
notification whenever first responder changes, or scheduling a method
to be performed whenever an event ends /eg. by
performSelector:withObject:afterDelay:0/, which would check current
first responder and do that externally; there can be other, easier way
which I haven't considered).
Well, yes, I guess it is the easier ways that you haven't considered that I
was looking for. ;-)
But maybe there's not a way to do this quite a simply as I would like,
which is fine, I guess...I considered subclassing NSResponder and using
+poseAsClass:, but it seemed a little bit heavy handed; only a small
fraction of the NSResponder-derived objects in my program will have any
need to notify when they get/lose first responder status.
Subclassing NSWindow and overriding -makeFirstResponder: seems maybe more
straightforward (if that works, I'll have to check). That way, I could
limit the scope of my hacking to the windows that actually need this
behavior...
Anyway, bright ideas still welcome, otherwise I'll post to the list when I
have something that works all right...
--
Mason