Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Drag/Drop onto NSTextField

Drag/Drop onto NSTextField
Thread Tools
Brass
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Aug 1, 2004, 07:08 PM
 
NSTextField does not appear to allow drag & drop onto it by default. What's the best way to enable this? I imagine some fiddling with the window's field editor would be required? Why don't Apple have this enabled by default? I would have thought it was a natural candidate.
     
techtrucker
Senior User
Join Date: Feb 2003
Location: USA
Status: Offline
Reply With Quote
Aug 2, 2004, 08:37 AM
 
Ran into this myself a while back. I "cheated" and used an NSTextView, if you get rid of the scroll bar you can make it the same height as a text field. I know it's not the right solution but it's how I got around it...

Steve W
MacBook 2.0 160/2GB/SuperDrive
Lots of older Macs
     
Wevah
Senior User
Join Date: Nov 2001
Location: State of Denial
Status: Offline
Reply With Quote
Aug 2, 2004, 09:26 PM
 
You could just subclass NSTextField and implement the drag and drop routines yourself...
[Wevah setPostCount:[Wevah postCount] + 1];
     
Brass  (op)
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Aug 2, 2004, 10:01 PM
 
Originally posted by Wevah:
You could just subclass NSTextField and implement the drag and drop routines yourself...
It's not that simple... you'd have to implement it for the NSWindow's field editor, not for the field itself.

Using an NSTextView sounds a lot simpler (ie, no additional code required at all). Actually, are there any drawbacks at all to replacing an NSTextField with an NSTextView?
     
techtrucker
Senior User
Join Date: Feb 2003
Location: USA
Status: Offline
Reply With Quote
Aug 3, 2004, 05:48 AM
 
I didn't experience any drawbacks really...The text view does look a little different from a text field (the frame), and you can't use the same functions for getting or setting the contents of text views as you do for text fields. If that doesn't bother you I say give it a try.

Steve W
MacBook 2.0 160/2GB/SuperDrive
Lots of older Macs
     
Brass  (op)
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Aug 3, 2004, 05:59 PM
 
Originally posted by techtrucker:
I didn't experience any drawbacks really...The text view does look a little different from a text field (the frame), and you can't use the same functions for getting or setting the contents of text views as you do for text fields. If that doesn't bother you I say give it a try.

Steve W
But there are functional equivalents, right? Eg, instead of "setStringValue", you use "setString". For some of the other "set..." methods, you may have to do some conversion to string first, but most such objects (eg, NSNumbers) have that built in anyway.
     
techtrucker
Senior User
Join Date: Feb 2003
Location: USA
Status: Offline
Reply With Quote
Aug 3, 2004, 10:08 PM
 
In my particular case I was only working with strings, so it was pretty easy. Instead of getting the string value with "stringValue" you just use "string" etc. But you're right, for numeric values you have to work the conversion out yourself.

Steve W
MacBook 2.0 160/2GB/SuperDrive
Lots of older Macs
     
Wevah
Senior User
Join Date: Nov 2001
Location: State of Denial
Status: Offline
Reply With Quote
Aug 4, 2004, 08:54 PM
 
Oh, are you talking about dragging and dropping into a specific position in the text field? I didn't catch that before. I thought it was just something like dragging a file onto a field and having the field filled with the filename. Nevermind, then.
[Wevah setPostCount:[Wevah postCount] + 1];
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 02:02 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,