diff options
author | kintel <kintel@b57f626f-c46c-0410-a088-ec61d464b74c> | 2010-02-02 01:07:02 (GMT) |
---|---|---|
committer | kintel <kintel@b57f626f-c46c-0410-a088-ec61d464b74c> | 2010-02-02 01:07:02 (GMT) |
commit | 5bc2ab00e8db95b0892a272e5fd5f333df28282d (patch) | |
tree | be28dcc35b3e915b34466f3869f1c5edfa4e752f /src/AppleEvents.cc | |
parent | 72513cb5cfa5bb7c11f873e796fa2054e8e3018e (diff) |
Experimental Apple Event hack; you can now do 'tell application "OpenSCAD" to reload'
git-svn-id: http://svn.clifford.at/openscad/trunk@410 b57f626f-c46c-0410-a088-ec61d464b74c
Diffstat (limited to 'src/AppleEvents.cc')
-rw-r--r-- | src/AppleEvents.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/AppleEvents.cc b/src/AppleEvents.cc new file mode 100644 index 0000000..470c4f3 --- /dev/null +++ b/src/AppleEvents.cc @@ -0,0 +1,32 @@ +#include <Carbon/Carbon.h> +#include <QApplication.h> +#include "MainWindow.h" + +extern "C" { + OSErr eventHandler(const AppleEvent *ev, AppleEvent *reply, SRefCon refcon); +} + +OSErr eventHandler(const AppleEvent *, AppleEvent *, SRefCon ) +{ +// FIXME: Ugly hack; just using the first MainWindow we can find + MainWindow *mainwin = NULL; + foreach (QWidget *w, QApplication::topLevelWidgets()) { + mainwin = qobject_cast<MainWindow*>(w); + if (mainwin) break; + } + if (mainwin) { + mainwin->actionReloadCompile(); + } + return noErr; +} + +void installAppleEventHandlers() +{ + // Reload handler + OSErr err = AEInstallEventHandler('SCAD', 'relo', NewAEEventHandlerUPP(eventHandler), 0, true); + require_noerr(err, CantInstallAppleEventHandler); + return; + +CantInstallAppleEventHandler: + fprintf(stderr, "AEInstallEventHandler() failed: %d\n", err); ; +} |