|
|
Drag/Drop onto NSTextField
|
|
|
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
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.
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Feb 2003
Location: USA
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
You could just subclass NSTextField and implement the drag and drop routines yourself...
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
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?
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Feb 2003
Location: USA
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
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.
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Feb 2003
Location: USA
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
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 Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|