Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

juliana42

macrumors newbie
Original poster
May 19, 2009
2
0
As we know, if Nstextfield gets the focus, we can simply drag a file or a folder from finder then drop in the textfield, the textfield will be filled with the path you dragged.
but now I must disable this function to only allow the path of certain file types be dragged into the textfield, for example, the file suffix is .pdf. how should I do?

at first, I want to find out whether this function is due to the drag and drop function in the textfield. so I add some code: unregisterdraggedtypes in the subclass from Nstextfield. but it still works on the function of drag and drop from finder. How can I disable it?

any help will be appreciated!
 
Yes, I think it can work with your method. Thank u very much.

But then I found that when the textfield is not editable, it won't accept the dropped path from finder. So I made it into that once I drag-enter the small view which contains the textfield, I set the textfield to be uneditable. If the path is acceptable, I will set it into the textfield. When it drag-exit, the textfield will be set to editable.

but this is just a workround. I still don't know how to prevent the function in the textfield.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.