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: Ondra Cada <email@hidden>
- Date: Sun, 16 Sep 2001 11:13:09 +0200
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.
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).
If you know of the change, the rest is easy -- just use the NSView
primitives to get the current first responder's frame, and scroll to the
desired point by sending the NSClipView (not the NSScrollView!) the
scrollToPoint: message.
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc