Re: How can I prevent drag-and-drop initiation in an NSTextField
Re: How can I prevent drag-and-drop initiation in an NSTextField
- Subject: Re: How can I prevent drag-and-drop initiation in an NSTextField
- From: Michael Crawford <email@hidden>
- Date: Tue, 16 Aug 2011 15:15:05 -0400
On Aug 16, 2011, at 2:44 PM, Quincey Morris wrote:
> On Aug 16, 2011, at 11:26 , Michael Crawford wrote:
>
>> I'm working on touch based museum exhibits, which run on Mac mini's. Suffice it to say I don't want to allow the movement of text.
>>
>> On Aug 16, 2011, at 2:02 PM, Kyle Sluder wrote:
>>
>>> On Tue, Aug 16, 2011 at 10:15 AM, Michael Crawford
>>> <email@hidden> wrote:
>>>> I have a window that contains an NSTextField instance. When the textfield contains text, I can select it with a single click. I want to preserve that behavior. When I click (mouseDown) and hold, the cursor changes to an arrow and drag-and-drop (d&d) is initiated. I want to disable this behavior.
>
> This (your latest comment) would have been good information to include in your original post.
>
> Based on that information, it's clear that the real problem here is that you're abusing NSTextField. The real solution is to rethink your UI conceptualization.
>
> If your touch target (the text) is actually behaving as a button, then you can use a borderless NSButton.
>
> If your touch target has slightly more idiosyncratic behavior -- it's like a button but NSButton doesn't do exactly what you want, or it's not like a button at all -- then you should be writing a custom control.
>
> Keep in mind that "selecting the text" probably isn't your users' conceptual framework. They are probably thinking in terms of "getting details on that topic" or something of that sort. Translating that directly into a Cocoa concept such as a selected NSTextField is probably a little too reductive.
>
>
Sorry Quincey but I'm not using the textfield as a button. It is a control that displays text for a virtual keyboard. As for not giving enough information at the start, I'm limited in how much of this project I can describe due to confidentiality agreements.
That being said, I'm simply trying to figure out how to disable the initiation of a drag and drop sequence from the user holding his/her finger (left mouse button) down on the textfield for too long. Really they should not be touching the textfield at all but it is on the screen and it is possible, so it will happen.
In the following post, Conrad asks a good question:
> I assume you meant NSTextField not NSTextView? I'm working on touch
> based museum exhibits, which run on Mac mini's. Suffice it to say I
> don't want to allow the movement of text.
If that's your goal, why don't you just setEditable:NO ?
I tried that. The only problem is that then I cannot display the keys the user taps as they happen. I'm injecting keyboard events and the textfield is the responder. I could bypass the keyboard input altogether and just have the keyboard buttons add the appropriate character to a string which is then written to the textfield but we have other reasons for wanting this to response as if a real keyboard was plugged in.
Please don't focus on the constraints I just described.
Does anyone know of a way to prevent drag and drop from an NSTextField? This is all I'm trying to accomplish.
I'm going to look into Kyle's statement regarding the "field editor." Thanks for all the feedback thus far.
-Michael
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden