[Top][All Lists]

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

NSTextField -becomeFirstResponder / NSTextView -copySelection

From: David Ayers
Subject: NSTextField -becomeFirstResponder / NSTextView -copySelection
Date: Sat, 18 May 2002 15:13:28 +0200

Hello Everyone,

I'm trying improve the NSTextFields firstResponder mechanics. Here is my
situation: So that a [aWindow makeFirstResponder:aTextField] actually makes
aTextField firstResponder which accepts input (if aWindow is key of course),
the NSTextField -becomeFirstResponder must setup the field editor for
aTextField and select the current text. I tried this by
invoking -selectText:.

So far, so good. Yet when clicking into aTextField, NSWindow's -sendEvent:
first makes aTextField first responder and then invokes -mouseDown:. This is
fine except, that the call to -selectText: of my -becomeFirstResponder
invokes the cells -selectTextWithFrame:inView:editor:delegate:start:length:
which invokes the field editors setSelectedRange:(affinity:stillSelecting:)
which invokes its -copySelection. This in turn get the "Selection"

OK this looks up the pasteboard with the pastboard server via DO allowing
the runloop to process the windows -displayIfNeeded displaying the new
selection of -becomeFirstResonder before the mouseDown: can reset the
selection to the actual coordinates of the event. The result is, that
on aTextField first results in the visible selection of the entire content
and then selecting the actual coordinates of the mouseDown:. :(

Now I'm wondering whether either to:
cache the fieldEditors needsDisplay state during -copySelection before
retrieving the pasteboard, set it to NO while the pasteboard is retrieved
then reseting it to the cached state, or whether this should be resolved by
another technique?

I'm also wondering, why
NSTextViews -setSelectedRange:affinity:stillSelecting:
copies the selection to the pasteboard in the first place?


reply via email to

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