Re: highlighting menu item in main menu bar
Re: highlighting menu item in main menu bar
- Subject: Re: highlighting menu item in main menu bar
- From: "email@hidden" <email@hidden>
- Date: Mon, 1 Jun 2009 11:25:41 -0700
hi peter,
thanx for the reply.
i believe i understand your reply. i've never driven the run loop
forward by hand before, but i think i could figure that out. but
before i embark down that path, some quick questions that perhaps you
could help me with:
1) if the executing script (from the sub task) causes my app to
display a dialog that requires user input, would this be blocked by
driving the run loop manually from within the initiating menu item's
action method?
2) the reason i went to using a sub task was because of problems with
-[NSScriptCommand suspendExecution] (see below). do you know if i
might have similar problems if i'm driving the run loop manually? (or
am i destined to go down this path and see what happens? :-( )
thanx,
ken
At 11:10 AM -0700 6/1/09, Peter Ammon wrote:
Hi Ken,
The menu item unhighlights after the menu item's action is finished.
If user input should be blocked while the script is running, then
you should register for the NSTaskDidTerminateNotification and then
drive the main run loop forwards from within your menu item's action
method, until you get the notification.
On the other hand, if the user can continue using your app as
normal, you should not show the menu item highlighted, because the
user might want to choose different menu items.
On Jun 1, 2009, at 9:34 AM, email@hidden wrote:
my app has a scripts menu item (in the main menu bar). the items in
this menu correspond to applescript files the user has placed in my
application support folder. when the user selects one of these menu
items, i execute the appropriate script. i execute the script in a
(sub) task (NSTask). i do it this way because i discovered (the
hard/empirical way) that if an executing script, executes
functionality in my app that calls -[NSScriptCommand
suspendExecution], then the executing of that script will
erroneously terminate early. using a sub task solves this problem.
in my app, when i launch this task, i register for the
NSTaskDidTerminateNotification and in my notification routine, i
display any errors returned.
this all works fine... except that as soon as i return from
launching the sub task, the menu item (in the main menu bar) for
the scripts menu un-highlights. i would like this to remain
highlighted until my notification routine is called, in order to
provide feedback to the user that his/her script is still executing.
is this possible? if so, could someone provide any code and/or
documentation pointers?
thanx,
ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden