RE: Reliable way to do something on shutdown?

2013-06-19 Thread Paul D. DeRocco
 From: J. Landman Gay
 
 ShutdownRequest is sent when the user tries to quit. 
 CloseStackRequest 
 is sent when they try to close a window, like when they click on the 
 close box.

Handling closeStack, and calling shutdown if it's the main stack, seems to
solve the problem. Just in case, I wrote the shutdown handler so that if
it's called twice, nothing bad will happen, so that should be safe no matter
how it works under OS X or Linux.

Now, if only someone knew the answer to my hilitedLine question. (Nudge,
nudge.)

-- 

Ciao,   Paul D. DeRocco
Paulmailto:pdero...@ix.netcom.com 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Reliable way to do something on shutdown?

2013-06-19 Thread Terry Judd

On 19/06/2013, at 04:31 PM, Paul D. DeRocco wrote:

 From: J. Landman Gay
 
 ShutdownRequest is sent when the user tries to quit. 
 CloseStackRequest 
 is sent when they try to close a window, like when they click on the 
 close box.
 
 Handling closeStack, and calling shutdown if it's the main stack, seems to
 solve the problem. Just in case, I wrote the shutdown handler so that if
 it's called twice, nothing bad will happen, so that should be safe no matter
 how it works under OS X or Linux.

One more thing - if you have a special clean up routine then you'll need to 
handle the user quitting using a keyboard shortcut (cmd-Q) separately on OSX. 
Something like this...

on appleEvent pClass,pID,pSender
   switch (pClass  pID)
  case aevtquit
 myShutdownRoutine
 pass appleEvent
 break
  default
 pass appleEvent
 break
   end switch
end appleEvent

 
 Now, if only someone knew the answer to my hilitedLine question. (Nudge,
 nudge.)

Not sure what's going on there. Have you tried an opencard handler? Or tried 
using a 'send' to trigger the change?

Terry...

 
 -- 
 
 Ciao,   Paul D. DeRocco
 Paulmailto:pdero...@ix.netcom.com 
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode
 

Dr Terry Judd
Senior Lecturer in Medical Education
Medical Eduction Unit
Faculty of Medicine, Dentistry  Health Sciences
The University of Melbourne





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Reliable way to do something on shutdown?

2013-06-19 Thread J. Landman Gay

On 6/19/13 2:11 AM, Terry Judd wrote:


One more thing - if you have a special clean up routine then you'll need to 
handle the user quitting using a keyboard shortcut (cmd-Q) separately on OSX. 
Something like this...

on appleEvent pClass,pID,pSender
switch (pClass  pID)
   case aevtquit
  myShutdownRoutine
  pass appleEvent
  break
   default
  pass appleEvent
  break
end switch
end appleEvent


Just curious why you'd need an AppleEvent. Wouldn't a shutdown handler 
be enough? I've never had to use an AppleEvent for that, but would like 
to know what situation would require it.




Now, if only someone knew the answer to my hilitedLine question. (Nudge,
nudge.)


Not sure what's going on there. Have you tried an opencard handler? Or tried 
using a 'send' to trigger the change?


That's what I'd do too. The engine does some internal housekeeping when 
it opens a card or a stack, and one of those things is automatic focus 
and automatic hiliting of list fields. Sometimes that gets in the way. 
Sending a message in time during preOpenCard to a handler that sets the 
hilite usually works because it happens after the automatic stuff completes.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Reliable way to do something on shutdown?

2013-06-19 Thread Terry Judd

On 20/06/2013, at 02:45 AM, J. Landman Gay wrote:

 On 6/19/13 2:11 AM, Terry Judd wrote:
 
 One more thing - if you have a special clean up routine then you'll need to 
 handle the user quitting using a keyboard shortcut (cmd-Q) separately on 
 OSX. Something like this...
 
 on appleEvent pClass,pID,pSender
switch (pClass  pID)
   case aevtquit
  myShutdownRoutine
  pass appleEvent
  break
   default
  pass appleEvent
  break
end switch
 end appleEvent
 
 Just curious why you'd need an AppleEvent. Wouldn't a shutdown handler be 
 enough? I've never had to use an AppleEvent for that, but would like to know 
 what situation would require it.


No, you're right. I was under the impression that cmd-q didn't trigger a 
shutdown request message. Perhaps it didn't in the distant past and I never 
registered the change.

Terry...

Dr Terry Judd
Senior Lecturer in Medical Education
Medical Eduction Unit
Faculty of Medicine, Dentistry  Health Sciences
The University of Melbourne





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Reliable way to do something on shutdown?

2013-06-18 Thread Terry Judd
What about using a closestack (or closestackrequest) handler?

Terry...

On 19/06/2013, at 10:07 AM, Paul D. DeRocco wrote:

 My app uses an external, which if not properly closed causes LiveCode, or my
 standalone, to remain as an orphan process under Windows until I forcibly
 kill it. So far, I haven't figured out how to intercept the shutdown when it
 comes from the close button in the corner of the window.
 
 First, I tried adding a shutdown handler to my main stack, which didn't
 work. Then, I noticed the note in the Dictionary, and created an invisible
 button which had a shutdown handler, and made its script a backscript, but
 that didn't work. Then, I noticed that the Dictionary said that shutdown
 is sent to the current card of the defaultStack, and not the stack itself,
 so I gave the card a shutdown handler, but that didn't work.
 
 I don't really care if there's some reason this can't work in the IDE, since
 I can just remember to manually close the external. But it has to work in
 the standalone.
 
 My app, in case it matters, has a main stack with one card, and three
 subsidiary stacks for modal dialog boxes, none of which are open when the
 program is shut down. It works fine if I call quit from a menu handler,
 but not when I click the X in the corner. What's the right way to do this?
 
 -- 
 
 Ciao,   Paul D. DeRocco
 Paulmailto:pdero...@ix.netcom.com 
 
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode
 

Dr Terry Judd
Senior Lecturer in Medical Education
Medical Eduction Unit
Faculty of Medicine, Dentistry  Health Sciences
The University of Melbourne





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Reliable way to do something on shutdown?

2013-06-18 Thread Phil Davis

Hi Paul,

Maybe a shutDownRequest handler in the script of your mainStack would do 
the job. In effect this lets you pause the shutdown process before it 
does anything, make sure your external is closed, then pass 
shutdownRequest. I think I would start there. Or 'closeStackRequest' 
like Terry suggested - it would work in the IDE or the standalone. That 
might be a better approach.


Phil Davis


On 6/18/13 5:07 PM, Paul D. DeRocco wrote:

My app uses an external, which if not properly closed causes LiveCode, or my
standalone, to remain as an orphan process under Windows until I forcibly
kill it. So far, I haven't figured out how to intercept the shutdown when it
comes from the close button in the corner of the window.

First, I tried adding a shutdown handler to my main stack, which didn't
work. Then, I noticed the note in the Dictionary, and created an invisible
button which had a shutdown handler, and made its script a backscript, but
that didn't work. Then, I noticed that the Dictionary said that shutdown
is sent to the current card of the defaultStack, and not the stack itself,
so I gave the card a shutdown handler, but that didn't work.

I don't really care if there's some reason this can't work in the IDE, since
I can just remember to manually close the external. But it has to work in
the standalone.

My app, in case it matters, has a main stack with one card, and three
subsidiary stacks for modal dialog boxes, none of which are open when the
program is shut down. It works fine if I call quit from a menu handler,
but not when I click the X in the corner. What's the right way to do this?



--
Phil Davis


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


RE: Reliable way to do something on shutdown?

2013-06-18 Thread Paul D. DeRocco
 From: Phil Davis
 
 Maybe a shutDownRequest handler in the script of your 
 mainStack would do 
 the job. In effect this lets you pause the shutdown process before it 
 does anything, make sure your external is closed, then pass 
 shutdownRequest. I think I would start there.

Actually, that's where I did start, and it didn't work either.

 Or 'closeStackRequest' 
 like Terry suggested - it would work in the IDE or the 
 standalone. That might be a better approach.

I'll try that this evening. But I wish I understood why what should
obviously work, doesn't.

-- 

Ciao,   Paul D. DeRocco
Paulmailto:pdero...@ix.netcom.com 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Reliable way to do something on shutdown?

2013-06-18 Thread Terry Judd
Are you making sure any other open stacks are being closed as well (for example 
in a closeStack or closeStackRequest message handler)? I've also had trouble 
with revBrowser in the past and always implicitly 'destroyed' any browser 
instances as I was cleaning up prior to a quit.

Terry...

On 19/06/2013, at 10:59 AM, Paul D. DeRocco wrote:

 From: Phil Davis
 
 Maybe a shutDownRequest handler in the script of your 
 mainStack would do 
 the job. In effect this lets you pause the shutdown process before it 
 does anything, make sure your external is closed, then pass 
 shutdownRequest. I think I would start there.
 
 Actually, that's where I did start, and it didn't work either.
 
 Or 'closeStackRequest' 
 like Terry suggested - it would work in the IDE or the 
 standalone. That might be a better approach.
 
 I'll try that this evening. But I wish I understood why what should
 obviously work, doesn't.
 
 -- 
 
 Ciao,   Paul D. DeRocco
 Paulmailto:pdero...@ix.netcom.com 
 
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode
 

Dr Terry Judd
Senior Lecturer in Medical Education
Medical Eduction Unit
Faculty of Medicine, Dentistry  Health Sciences
The University of Melbourne





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Reliable way to do something on shutdown?

2013-06-18 Thread J. Landman Gay

On 6/18/13 7:59 PM, Paul D. DeRocco wrote:

From: Phil Davis

Maybe a shutDownRequest handler in the script of your
mainStack would do
the job. In effect this lets you pause the shutdown process before it
does anything, make sure your external is closed, then pass
shutdownRequest. I think I would start there.


Actually, that's where I did start, and it didn't work either.


Or 'closeStackRequest'
like Terry suggested - it would work in the IDE or the
standalone. That might be a better approach.


I'll try that this evening. But I wish I understood why what should
obviously work, doesn't.



ShutdownRequest is sent when the user tries to quit. CloseStackRequest 
is sent when they try to close a window, like when they click on the 
close box.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


RE: Reliable way to do something on shutdown?

2013-06-18 Thread Paul D. DeRocco
 From: J. Landman Gay
 
 ShutdownRequest is sent when the user tries to quit. 
 CloseStackRequest 
 is sent when they try to close a window, like when they click on the 
 close box.

Sounds like I need to handle both, then. It seems wrong to me that there
is no message that universally indicates shutdown, no matter how it is
invoked, but I guess I can live with it.

-- 

Ciao,   Paul D. DeRocco
Paulmailto:pdero...@ix.netcom.com 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Reliable way to do something on shutdown?

2013-06-18 Thread J. Landman Gay

On 6/18/13 10:51 PM, Paul D. DeRocco wrote:

From: J. Landman Gay

ShutdownRequest is sent when the user tries to quit.
CloseStackRequest
is sent when they try to close a window, like when they click on the
close box.


Sounds like I need to handle both, then. It seems wrong to me that there
is no message that universally indicates shutdown, no matter how it is
invoked, but I guess I can live with it.



Well, on a Mac, closing the last window doesn't shut down the app. The 
app stays resident and sits there with nothing but its menu bar showing, 
waiting for you to choose Quit. :)


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Reliable way to do something on shutdown?

2013-06-18 Thread J. Landman Gay

On 6/18/13 11:03 PM, J. Landman Gay wrote:

On 6/18/13 10:51 PM, Paul D. DeRocco wrote:

From: J. Landman Gay

ShutdownRequest is sent when the user tries to quit.
CloseStackRequest
is sent when they try to close a window, like when they click on the
close box.


Sounds like I need to handle both, then. It seems wrong to me that
there
is no message that universally indicates shutdown, no matter how it is
invoked, but I guess I can live with it.



Well, on a Mac, closing the last window doesn't shut down the app. The
app stays resident and sits there with nothing but its menu bar showing,
waiting for you to choose Quit. :)



I take that back -- closing the *last* window does shut it down. But it 
isn't always the last window the user is closing, so we need two messages.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


RE: Reliable way to do something on shutdown?

2013-06-18 Thread Paul D. DeRocco
 From: J. Landman Gay
 
  Well, on a Mac, closing the last window doesn't shut down 
  the app. The
  app stays resident and sits there with nothing but its menu 
  bar showing, waiting for you to choose Quit. :)
 
 I take that back -- closing the *last* window does shut it 
 down. But it 
 isn't always the last window the user is closing, so we need 
 two messages.

Oh bugger, I hope this doesn't mean that it will work differently on a Mac.
I don't have a Mac to test it on.

-- 

Ciao,   Paul D. DeRocco
Paulmailto:pdero...@ix.netcom.com 


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode