.CloseWindow proc not triggered


#1

does .CloseWindow work in panx?

i just wrote one that doesn’t; that is, the proc works but it isn’t triggered when i close the window.


#2

No, it is not currently supported in Pan X. Unfortunately info(“formevent”) does not include a “Close” event so I don’t believe there is any practical way to trap a closing form.


#3

disappointing, but thanks.


#4

In the older Mac operating systems (pre OS X), a program had to do everything itself. So for example when a user clicked on the “close” button, that click would be sent to the program (in this case Panorama 6) which would then ask Apple to close the window. So it was no problem to insert the ability to run some Panorama code in this situation, and even for the the Panorama code to interrupt the process of closing the window.

In OS X, this is all handled by Apple’s code, without involving the application program. So to get a .CloseWindow procedure to work the way it used to, Panorama would somehow have to insert some custom code into Apple’s code. That may be possible, but so far I haven’t figured out how to do that, at least not reliably in all situations where a window can close.


#5

thanks for explaining.


#6

I get around this problem by putting this in my .Initialize procedure:

definehotkeys "database","command-w", {save closefile}

You can enter whatever code you want to run for that particular database.


#7

Your solution only works if the user always uses Command-W to close the window, and never clicks the close box with the mouse, or by choosing Close Window from the File menu.

“command-w”, {save closefile}

I see two other potential pitfalls here. First, why the save? Totally unnecessary in Panorama X. Secondly, if the database has more than one window, closing the entire file when pressing Command-W is non standard. It should only close the current window.

A slightly better solution would be to customize the File menu using filemenubar and the standardfilemenu( function.

This still wouldn’t handle clicking the close box, but would work properly with the File menu.


#8

I am finding some situations where the database is not saving when I close its window. I think that when I check a bunch of stock prices, it may not save.


#9

When you do that (check a bunch of stock prices) with a procedure, Panorama X maybe will not recognize the database as changed. It needs an undoable action to consider a database as changed.

The documentation about “Undo” tells you how to make a procedure undoable: Add a startdatabasechange statement to the begin of your procedure code.


#10

Actually, sometimes it is handy not to have it be saved. But I wish the dialog would come up and ask me.


#11

You decide: System Preferences > General > Lower Section: “Ask if changes shall be saved”


#12

Because this is what I get if I close the file after adding a new record and putting some stuff in it:

29 pm

… and because I always want to save this file’s changes.


#13

Aha, you have enabled the option “Ask to keep changes when closing documents” in System Preferences. Otherwise, it would just save without asking you (which is the default).


#14

That’s correct - I don’t ever want automatic saves in any application.