Hi

I am seeing annoying flickering when resizing a status bar item using a custom view.

I tried using
        * [statusItem setLength:XX.X] and
        * [customView setFrame:newFrame]
Both methods produce flickering. I investigated further to see where exactly is the flicker happening.

The problem is probably best illustrated with the debugger using the sample code below:

There are 3 breakpoint
2 before and after "setFrame" in the action "add" and
1 more at the start of drawRect in the custom view

1. When the "add" action is invoked (look at the sample code below), just before setFrame is called this is a screen capture of the status item (it is good): http://grkov.com/tmp/pic1.png

2. Step Over, and while within setFrame, the breakpoint in SBView drawRect is reached. This is a screen capture of that (not good, we see the problem): http://grkov.com/tmp/pic2.png

Here we see why the flicker occurs. The custom view is shifted 10 pixels to the left and the new 10 pixels show up as white.

3. Step over the drawRect (white area is still there): 
http://grkov.com/tmp/pic3.png

And then hit continue

4. The breakpoint after "setFrame" (called in step 1) is reached. And at this point the status item looks good: http://grkov.com/tmp/pic4.png

But that is not the case with step 2 and 3.

(By the way, there is a second call to drawRect after the action "add" returns.)

Does anyone understands what is going on and how to go about further debugging this?

Thank you for your input and help,
Vance

#import <Cocoa/Cocoa.h>
#import "SBView.h"

@interface MyView : NSView {
        NSStatusItem *statusItem;
        SBView *siView;
}

- (IBAction)onClick:(id)o;
- (IBAction)add:(id)o;
- (IBAction)remove:(id)o;

@end

#import "MyView.h"

@implementation MyView

- (IBAction)create:(id)o
{
        NSStatusBar *statusBar = [NSStatusBar systemStatusBar];
statusItem = [[statusBar statusItemWithLength:NSVariableStatusItemLength] retain];
                
        siView = [[SBView alloc] initWithFrame:NSMakeRect(0,0,30,20)];
        [statusItem setView: siView];
}

- (IBAction)add:(id)o
{
        NSRect f = [[statusItem view] bounds];
        f.size.width += 10;
        [[statusItem view] setFrame: f ];
        
        //[statusItem setLength:[si length] + 10];
}

- (IBAction)remove:(id)o
{
        NSRect f = [[statusItem view] frame];
        f.size.width -= 10;
        [[statusItem view] setFrame: f ];

        //[statusItem setLength:[si length] - 10];
}

@end

///////////////////////////// Cusotm View Class /////////////////////////////////////////////

@interface SBView : NSView {
}

@implementation SBView

- (void)drawRect:(NSRect)r
{       
        NSString *t = @"display string";
        [t drawAtPoint:NSMakePoint(0,0) withAttributes:nil];
}

@end
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to