on launch vs on open control

I want my application to function two distinct ways…one way when files are dropped on it and another way when it’s double clicked. I’ve read several posts about how to add the “on open” handler to the project and I’ve got that working. My issue, however, is I have code in my on launch that I don’t want executed when files are dropped on the application. For simplicity, i’ve tried to illustrate what i have below.


on launched theObject
	display dialog "I was double clicked"
end launched

on open theObject
	display dialog "I received a file drop"
	quit
end open

Is there another handler I can use that only gets called when an application is double clicked? or a way in “on launched” to check if the application received files as input?

Hi,

you could use the idle handler, which will be called after the on open handler.
The executed property prevents the code to be called more than once


property dropped : false
property executed : false

on idle
	if not dropped and not executed then
		display dialog "I was double clicked"
		set executed to true
	end if
	quit
end idle

on open names
	display dialog "I received a file drop"
	set dropped to true
end open

I guess I could give that a shot. I can’t believe there isn’t a built in handler to do this…I was really hoping my ignorance would show and someone would have a simple built in solution. Any other thoughts out there?

Alright StefanK, I have to give you credit…I went ahead and tried out your proposed option and it seems to be working better then I had anticipated. Thanks much for the work around idea to my issue. It’s greatly appreciated. :smiley: