Dragging to text fields
Dragging to text fields
- Subject: Dragging to text fields
- From: Bill Cheeseman <email@hidden>
- Date: Fri, 15 Mar 2002 13:11:38 -0500
Is there a standard or recommended way to implement dragging to text fields
in Cocoa?
I'm having difficulty implementing Aqua HI-compliant behavior, especially
with respect to displaying an insertion point under the mouse in the current
contents of the destination text field. Especially if the destination window
is in the background and the destination text field is not currently
selected.
I looked to the Mail application for a behavior model, but it does things
that I don't think are good UI. For example, in the message composition
window, it puts a border around unselected text fields when you drag to them
(To:, CC: or Subject:), but it tracks an insertion point in the selected
field and the message text field. This suggests that the Mail developers are
having trouble figuring this out, too.
I'm heading in this direction: My text field class adopts the
NSDraggingDestination protocol. My implementation of draggingUpdated: gets
the sender's draggingLocation, a point. I think I will use NSTextInput's
characterIndexForPoint: to convert this to a character index within the text
field's field editor (I probably have to adjust for horizontal scrolling, if
any). Then I think I will use NSCell's
selectWithFrame:inView:editor:delegate:start:length: method to actually put
an insertion point in the text field.
But it's giving me some trouble. I can't find any documentation or example
code for guidance. I don't know whether this will work when the window is in
the background and the text field is not selected. And so far, I can't get
it to work even when the destination is active and selected.
Am I barking up the wrong tree?
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
Croquet Club of Vermont -
http://members.valley.net/croquetvermont
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.