"unregistering" drag type

Hello,
I’ve written an Applescript Studio app that allows me to drag and drop files from the Finder and then populate a text field with it’s name and path. The register drag types is being done in an awake from nib handler. There is a drop down box, in the window, which when a certain item is selected, the drag and drop field should become inactive. I can dim the text field using enabled false, however, I’ve noticed that the text field still responds to a drag and drop, placing the filename into the text field (albeit greyed out). Is there a way to “unregister”, so to speak, a text field so it will no longer interact with a drag and drop? Additionally, I might like to reactivate it at some point in the future, as well to again receive drag and drop motions.

Thanks
kind regards,
… tony

You’ll need to add some code which will evaluate the current “drop-ability” you desire, and then programmatically limit the text field from executing the code you’ve provided that handles your drops. Once the text field is configured to receive drops, it doesn’t seem reasonable to try to undo all of that. Instead, simply set up your code to accept or ignore drops based on certain criteria.

property canReceiveDrops : true

on drop theObject drag info dragInfo
	if canReceiveDrops then
		--> insert your code to evaluate the drops here
	else
		beep
	end if
end drop

(* Example code for toggling "drop-ability" *)
on clicked theObject
	if name of theObject is "disableDrops" then
		set canReceiveDrops to false
	else if name of theObject is "enableDrops" then
		set canReceiveDrops to true
	end if
end clicked

j

Thanks jobu, that is a good idea. I never looked at it from that angle. After reading your suggestion, I realized there is an even shorter way for me to do it, still using your method, with a single IF statement. Since a popup menu is toggling the “enabled” property of the text field, I can check whether the box is enabled or not. If it is, set the contents, if not, ignore it. Fantastic… thanks again!

tell window "win"
	if enabled of text field objName then
		set contents of text field objName to anItem
	end if
end tell