From: Jim I. <ji...@ap...> - 2005-01-31 18:07:49
|
Note, originally we didn't really think that the default set of menu's that come up in the Wish shell would be more than a convenience. It was assumed that anybody that was designing a more serious application would need to install their own menus anyway. So these are just there in order that somebody playing around with the wish shell could has SOME menus. This isn't a terribly important comment, except it might explain why a comparatively little amount of thought went into setting up these menus... Jim On Jan 31, 2005, at 2:42 AM, Alastair Davies wrote: > For most applications, the command: > bind all <Command-q> exit > will put into effect the keyboard shortcut implied by the cloverleaf > decoration of the Quit item in the application menu. > If your application needs to perform any actions before shutting down, > e.g. > prompting the user to save modified files etc., you could bind an > alternative procedure to the keyboard shortcut. This binding, > however, is > obviously only invoked if the user uses the keyboard shortcut. If the > user > uses the Quit menu item, the Wish Shell default handler will evaluate > the > exit command and not your alternative. > To ensure that both the keyboard shortcut Command-q and the Quit menu > item > invoke the same procedure, it is necessary that that procedure should > be > called "exit". On the Wiki, DAS makes the suggestion [1] to rename the > standard "exit" command, and replace it with your own, for example as > follows: > rename exit wishExit > proc exit {} { > if [string match yes [tk_messageBox -message "Really quit?" -type > yesno]] > wishExit > } > bind all <Command-q> exit > I have previously suggested a patch [2] to Wish Shell, which alters the > default handler to check for the presence of the command > ::tk::mac::Quit. > If this command is found, it is executed instead of the exit command. > The > thinking behind this alternative is by analogy with the other default > handlers, which call procedures such as tk::mac::OpenDocument {args}. > In regard specifically to the cloverleaf decorations on the application > menu, I am not aware of any means of altering these at the script > level, > though I notice that the Wish Shell console removes the decoration > from the > Quit menu item when it itself is being used. > A final precaution to be aware of (at least in my experience on MacOS > X 10.2 > and Tcl/Tk 8.4.9) is that the bindings do not always reliably fire, > and it > is often necessary to switch your application into the background and > back > into the foreground for them to come into effect. > I hope this helps. > Kind regards, Alastair > [1] http://wiki.tcl.tk/12987 > [2] > http://sourceforge.net/tracker/index.php? > func=detail&aid=1105284&group_id=12 > 997&atid=362997 > ------------------------------------------------------- > This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting > Tool for open source databases. Create drag-&-drop reports. Save time > by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. > Download a FREE copy at http://www.intelliview.com/go/osdn_nl > _______________________________________________ > Tcl-mac mailing list > Tc...@li... > https://lists.sourceforge.net/lists/listinfo/tcl-mac |