Page 1 of 1

shutDownRequest

Posted: Fri Oct 05, 2007 1:02 pm
by songe
Howdy,
I put the following handler into the stack script and it appears that it is being completely ignored? Anyone know why?

on shutdownRequest -- confirm with the user:
answer question "Are you sure you want to quit?" with "Yes" or "No"
if it is "Yes" then pass shutdownRequest -- allow to quit
end shutdownRequest

P.S. This is just the script that was in the documentation. I just copied to make sure I wasn't misspelling anything. It appears that it's just being completely ignored.

Posted: Fri Oct 05, 2007 2:22 pm
by Mark
Songe,

What are you expecting to trigger the script?

Mark

Re: shutDownRequest

Posted: Fri Oct 05, 2007 7:43 pm
by Lynn P.
songe wrote:Howdy,
I put the following handler into the stack script and it appears that it is being completely ignored? Anyone know why?

on shutdownRequest -- confirm with the user:
answer question "Are you sure you want to quit?" with "Yes" or "No"
if it is "Yes" then pass shutdownRequest -- allow to quit
end shutdownRequest

P.S. This is just the script that was in the documentation. I just copied to make sure I wasn't misspelling anything. It appears that it's just being completely ignored.
Hi Songe ~

This should work after building your app as a stand alone application. Have you tested it that way yet? You don't even have to have created any menus for your application yet with a Quit menu item. Rev will do that much for you.

Rev is still in control so I believe the stack will not be sent the shutdownRequest message. An actual application is the only thing that can receive that message (actually a SIGTERM signal sent from the operating system to an application), so Rev itself gets that message, not a stack in development. Once your stack is on it's own as a built application, it can then receive and respond to the message you put in the stack script.
At least, that's the way it works for me in OS X.

Posted: Fri Oct 05, 2007 11:19 pm
by songe
Ok. Thanks for the info. There are still some problems though.

1) When you quit through the menubar, the shutdownrequest handler is triggered. But it isn't when the top left button of those three buttons in the menubar is clicked. It'd be nice if I could get it to trigger then as well.

2) Something like the bottom 20 or so pixels of my window are getting cut off. I think it has something to do with the menubar.

3) I have a registration window. When I make changes to it and then quit, the state of that window does not change. So, if a person registers the software, are they going to have to reregister it every time?

4) I imported a graphic into my software, but in the standalone, it is all grayed out. When I use the menu option Import as Control/Image file, the only things it will let me select are .png images. And when I try to paste an image in, it pastes it in dithered. Is my software messed up? Should I reinstall?

Thanks. I'm a newbie here. I'm just coming over from SuperCard and HyperCard. I really appreciate the help.

Posted: Sat Oct 06, 2007 5:15 pm
by Lynn P.
Here are some answers to your questions Songe :-)
Hope they help you out...
1) When you quit through the menubar, the shutdownrequest handler is triggered. But it isn't when the top left button of those three buttons in the menubar is clicked. It'd be nice if I could get it to trigger then as well.
Just throw in a closestackRequest to trap for that too...
Put something like this in the stack script:

Code: Select all

on shutdownRequest -- confirm with the user:
  answer question "Are you sure you want to quit?" with "Yes" or "No"
  if it is "Yes" then pass shutdownRequest -- allow to quit
end shutdownRequest

on closestackRequest
    answer question "Are you sure you want to quit?" with "Yes" or "No"
      if it is "Yes" then pass closestackRequest -- allow to quit
end closestackRequest 
2) Something like the bottom 20 or so pixels of my window are getting cut off. I think it has something to do with the menubar.
Check out the windowBoundingRect in the Rev Documentation Dictionary area. It will take into account the menu and dock in a users environment and the taskbar if using Windows. You never know the screen size of your users machine, and the dock size is changible in OS X.
If you get the windowBoundingRect, you can set your stack size in a preOpenStack script accordingly.
3) I have a registration window. When I make changes to it and then quit, the state of that window does not change. So, if a person registers the software, are they going to have to reregister it every time?
How are you saving the changes? Do you write it out to file? Are you saving it in the stack? Remember, a stack can't save to itself. This is one of the things that was very hard to understand coming from a Hypercard experience.
Check out the Rev Documentation tutorials.
Click the Documentation button from the Rev application.
Click the Getting Started button. Click the Sample Projects button.
The top item will give an example of how to do this: "Preferences pane - saving to a stack or text file"
4) I imported a graphic into my software, but in the standalone, it is all grayed out. When I use the menu option Import as Control/Image file, the only things it will let me select are .png images. And when I try to paste an image in, it pastes it in dithered. Is my software messed up? Should I reinstall?
Make sure when you choose File->Import as Control->Image file..., that you choose "All Picture Files" from the "Enable" menu pop up button at the top of the resulting window. This will allow all types of image files to be chosen.

As far as the image being grayed out, what kind of image was being imported? Did you actually import it or reference it? Did you verify that the image is stored in your stacks Image Library (under the Development menu)?
Check out the keyword "paintCompression" in the Dictionary area of the Rev Documentation. While there, check out the "See Also" area on the page and click on "Image Types Reference".

Images can be finicky and I am no expert in this area, although there are folks here in the forum and on the Rev newsgroup list that are, so I'm sure one of them will come along and give you expert advice.
In my experience however, it is best to either import the actual image or reference it to make sure all image data is imported. Even then, such as animated .gif files, not all frames show up correctly. It really depends on how the original image was saved, I believe. I've never had problems importing .png, .jpg or .gif files or referencing them from an image object. I usually use .png's for the most part now because of the control over transparency. Referencing is a bit more difficult if you don't know about path files. If you move the file you are referencing on your hard disk, Rev may not be able to find it and if you don't account for this in your scripting, you or your end user may get a gray area where the image should be.
You can also bring images into your stack using the Image Library under the Development menu.