Sunday, January 21, 2018

#1 2009-02-24 05:45:12 pm

Shai1
Member
Registered: 2002-11-20
Posts: 123

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.

Applescript:


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?


Scripting...YAY!

Offline

 

#2 2009-02-25 03:45:20 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11483
Website

Re: on launch vs on open control

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

Applescript:


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


regards

Stefan

Offline

 

#3 2009-02-25 11:22:26 am

Shai1
Member
Registered: 2002-11-20
Posts: 123

Re: on launch vs on open control

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?


Scripting...YAY!

Offline

 

#4 2009-03-02 04:58:04 pm

Shai1
Member
Registered: 2002-11-20
Posts: 123

Re: on launch vs on open control

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.  big_smile


Scripting...YAY!

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)