Re: Show/Hide Toolbar Rendering Bug?
Re: Show/Hide Toolbar Rendering Bug?
- Subject: Re: Show/Hide Toolbar Rendering Bug?
- From: PGM <email@hidden>
- Date: Sat, 19 Aug 2006 16:36:18 -0400
Brian,
I noticed in my own app that the control goes back to normal again,
once the window is redrawn, e.g. when another window becomes key. So
it is possible to force the button to redraw when the toolbar is
shown. Unfortunately there is no notification for that, but you can
use NSWindowDidResizeNotification. A problem is that the correct
control will only be drawn after the animation is finished, which is
very ugly, but maybe this will point you in the direction of a good
workaround without private methods.
-(void)windowDidResize:(NSNotification *)notification
{
[[NSRunLoop currentRunLoop] cancelPerformSelector:@selector
(redisplayToolBar:) target:self argument:nil];
[[NSRunLoop currentRunLoop] performSelector:@selector
(redisplaySegmentedControl:) target:self argument:nil order:100 modes:
[NSArray arrayWithObject:NSDefaultRunLoopMode]];
}
//this method should be called after the animation has finished as
during the animation NSToolbar return NO for isVisible
-(void)redisplaySegmentedControl:(id)sender
{
if([toolbar isVisible] != visible && !visible){
[viewWithSegmentedControl setNeedsDisplay:YES];
visible = [toolbar isVisible];
}
}
The BOOL "visible" is a flag in my NSToolbar delegate, which prevents
the segmentedControl from being redrawn on every resize. I initialise
this BOOL when creating the toolbar:
[window setToolbar:toolbar];
visible = [toolbar isVisible];
Another workaround would be to take the Safari-route and use normal
NSButtons with tiffs of the segments (using different tiffs for
normal, clicked and disabled).
Good luck, Patrick
On 19-Aug-06, at 10:13 AM, Brian Amerige wrote:
Hi all,
I've run into this problem in a few apps, and I'm wondering if
there's a solution to it. I've got a standard NSToolbar with
NSToolbarItems, one of which being a segmented control.
The problem comes, however, when you hide, then show the toolbar,
the back/forward button (segmented control) is rendered improperly.
Ordinary:
<Picture 1.png>
After Show/Hide:
<Picture 2.png>
Any ideas?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40sympatico.ca
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden