On 15/01/2013, at 8:13 AM, Luther Fuller <email@hidden> wrote:
This is becoming a mess.
FWIW, it looks to me that you're using separate apps for two reasons: a way of getting the menu items in a dock tile, and a way of displaying a dialog while processing continues. If so, you can solve both those problems fairly easily by reworking your app in AppleScriptObjC.
You'd need to make a window in your Xcode project, turn off Visible at Launch, and add a progress spinner. In your code, you'd add properties for the dock menu, window, and spinner:
property theMenu : missing value property theWindow : missing value property theSpinner : missing value
And connect the latter two in the interface.
You would need have a handler that builds your dock menu, something like this:
on makeMenu() set my theMenu to current application's NSMenu's alloc()'s initWithTitle_("") set theSeparator to current application's NSMenuItem's separatorItem() tell theMenu addItemWithTitle_action_keyEquivalent_("Set Up", "doSetUp:", "") addItem_(theSeparator) addItemWithTitle_action_keyEquivalent_("Help", "doHelp:", "") addItemWithTitle_action_keyEquivalent_("Item 3", "doItem3:", "") end tell end makeMenu
And then handlers for each of the items:
on doSetUp_(sender) showWindow() -- do your set-up stuff here display dialog "setting up" hideWindow() end doSetUp_
on doHelp_(sender) -- show help here display dialog "help" end doHelp_
on doItem3_(sender) showWindow() -- do something else here display dialog "Item 3" hideWindow() end doItem3_
Showing and hiding the progress window would be two more handlers:
on showWindow() tell theSpinner setUsesThreadedAnimation_(true) startAnimation_(me) end tell theWindow's makeKeyAndOrderFront_(me) end showWindow
on hideWindow() theWindow's orderOut_(me) end hideWindow
You could also have them carry messages to suit.
You would call the makeMenu handler early on:
on applicationWillFinishLaunching_(aNotification) makeMenu()
Finally you'd need the handler to let the app know about the menu:
on applicationDockMenu_(sender) return theMenu end applicationDockMenu_
Then you could consolidate your code in one place.
|