From: Philip A. <phi...@sh...> - 2009-08-15 12:56:31
|
As previously mentioned, I've created a new implementation of the Tk scripting implementation. An example of how it works is at : <http://www.vcn.bc.ca/~philip/Wishbone.zip> In order to complete it as a backwards compatible snap-in replacement, I'd appreciate some discussion on a few particulars of the Tk compile- time and runtime. For the Tk.framework/Wish.app developer portion, since a Tk app isn't a regular Carbon app, I'm wondering if it would be possible to handle the incoming AppleEvents in the ReceiveNextEvent() handler? I know it can be done because I've used the technique myself in a Carbon app. However that app doesn't have any Tcl/Tk event loop interleaving and that could be a consideration. The reason for this request is due to the ordering of incoming AppleEvents with respect to the Application Carbon event handler. It's roughly this: ReceiveNextEvent() AppleEvent PreDispatch handler Application Carbon event handler AppleEvent handlers The main problem is that the name of the ShowPreferences handler script ("::tk::mac::ShowPreferences") is _hard-wired_ into the menu enabling function of "tkMacOSXEvent.c". This causes a problem with the new implementation because it seems to preclude having a new handler (with a different namespace and name) which can deal with extra parameters. In addition, the problem further exacerbated because wherever kHICommandPreferences is snagged in the Carbon event handlers, it takes precedence over the AppleEvent handler (as you can see by the ordering above). In the example Wishbone application (which I've rigged to illustrate) you should be able to see the problem by first choosing the Preferences menu item by the mouse, and then by using the keyboard <Command-,> shortcut. There are two results -- by the mouse, as expected, the proc is called once. But using the shortcut, it is called twice. Finally, using the example script call you can see that the expected result is not returned. The different results are logged by the app to a file on your desktop called: "WishboneLog.txt". The way I see it, the problem could be solved with the least amount of disruption if the AppleEvents were dispatched directly from the ReceiveNextEvent() handler before they got to any Application/Menu/ Window carbon event handlers. How to do it is described the CarbonEvents.h header file in the discussion for kEventClassAppleEvent. Just to note, there are two different techniques used for Leopard and later and pre-Leopard and the new call (AEProcessEvent()) is good because it avoids having to use an EventRecord. But I don't know all the details of the Tk event handling and the implications this would have. Alternately, I believe it could be handled in a similar fashion in Carbon event handers by returning eventNotHandedErr for kHICommandPreferences so the fallback to the AppleEvent would occur. With either of the above implemented, I believe it would be possible to have the code in tkMacOSXHLEvents.c do the Preferences menu enabling based on it's assessment of whether or not a handler for the specific 'aevt/pref' command responds rather than having a name hardwired into tkMacOSXEvent.c. § For Tk-based application developers you should be able to see the difference between the old-style Tk-app scripting dictionary and the one illustrated in Wishbone.app by dragging them to the Script Editor application. In particular, you should note that the 'open', 'print' and 'do script' commands can now accept and process files specified by URL. I've also implemented the standard "print settings" record for optional input to the 'print' command and would be especially interested to hear if anyone thinks it should have some extra members. For instance, you'll notice in the AppMain.tcl script ::AppleEvent::aevt::pdoc proc where the 'nstexttopdf' cups filter is used, I have to specify a PPD. I think it might be better to have the PPD able to be specified in the AppleScript call. Thanks! Philip Aker echo astwta@lvpc.dslh@nl | tr a-z@. p-za-o.@ Democracy: Two wolves and a sheep voting on lunch. |