Re: Removing delay for a menu in NSSegmentedControl?
Re: Removing delay for a menu in NSSegmentedControl?
- Subject: Re: Removing delay for a menu in NSSegmentedControl?
- From: "email@hidden" <email@hidden>
- Date: Tue, 26 May 2009 01:28:31 +0200
I had the same problem and ended up displaying the menu
programmatically in my control's action method. I hope someone can
provide a better solution...
NSPoint point = [segmentedControl convertPoint:[segmentedControl
frame].origin fromView:nil];
NSEvent *event = [NSEvent mouseEventWithType:NSLeftMouseUp
location:point modifierFlags:0 timestamp:[NSDate
timeIntervalSinceReferenceDate] windowNumber:[[segmentedControl
window] windowNumber] context:[[segmentedControl window]
graphicsContext] eventNumber:0 clickCount:1 pressure:0];
[NSMenu popUpContextMenu:popupMenu withEvent:event
forView:segmentedControl withFont:[NSFont systemFontOfSize:11]];
On Mon, May 25, 2009 at 9:51 PM, Mark Munz <email@hidden> wrote:
> There is an IBAction attached to the segment control that processes
> the other segment clicks and does nothing for the menu segment. If I
> completely disconnect the IBAction, the menu pops up instantly.
>
> However, if I connect it to an IBAction (even to an empty routine),
> the delay returns.
>
> The delay seems to be tied to whether or not there is a Sent Action
> attached to the control.
>
> On Mon, May 25, 2009 at 12:35 PM, Dave Keck <email@hidden> wrote:
>>> Right now, there is about about a 1-second delay after a click on a
>>> segment before its menu will appear.
>>>
>>> Is there a way to remove this delay in bringing up a menu attached to a segment?
>>
>> This isn't typical - if you create a new project and just drop a NSSC
>> in a window, you'll see there's no delay.
>>
>> You probably have something executing when the user clicks on it, and
>> so the NSSC isn't redrawn to reflect its new state until this code
>> finishes. Your best option in this case is to perform these actions in
>> the next iteration of the run loop. This can be done using a timer:
>>
>> [NSTimer scheduledTimerWithTimeInterval: 1.0 target: self selector:
>> @selector(performClickActions) userInfo: nil repeats: NO];
>>
>> Which will give the NSSC a chance to update immediately.
>>
>> David
>>
>
>
>
> --
> Mark Munz
> unmarked software
> http://www.unmarked.com/
> _______________________________________________
>
> 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
>
_______________________________________________
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