• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: launch broken in Mt Lion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: launch broken in Mt Lion


  • Subject: Re: launch broken in Mt Lion
  • From: Shane Stanley <email@hidden>
  • Date: Tue, 15 Jan 2013 14:20:13 +1100

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.

-- 
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: launch broken in Mt Lion
      • From: Luther Fuller <email@hidden>
References: 
 >launch broken in Mt Lion (From: Luther Fuller <email@hidden>)
 >Re: launch broken in Mt Lion (From: Luther Fuller <email@hidden>)
 >Re: launch broken in Mt Lion (From: Luther Fuller <email@hidden>)

  • Prev by Date: Re: apple bridging for applescript and python
  • Next by Date: Re: launch broken in Mt Lion
  • Previous by thread: Re: launch broken in Mt Lion
  • Next by thread: Re: launch broken in Mt Lion
  • Index(es):
    • Date
    • Thread