• 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
Cocoa's erasing the contents of my window.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cocoa's erasing the contents of my window.


  • Subject: Cocoa's erasing the contents of my window.
  • From: Rosyna <email@hidden>
  • Date: Mon, 5 May 2003 14:37:09 -0700

I have a Carbon kOverlayClassWindow which I get a CGContextRef for and draw directly into. Problem is, shortly after the Cocoa application it is in starts its event loop, my Carbon window fills with a white rectangle. This does not seem to happen in Carbon applications. The code I am using is:


static pascal OSStatus MyWindowEventHandler (

EventHandlerCallRef myHandler, //1

EventRef theEvent, //2

void* userData)
{
NSLog(@"Calling things");
return noErr;
}


-(void)awakeFromNib
{
CGRect box;
WindowRef win;
Rect bounds={0,0,200, 300 };
CGContextRef shieldContext;
WindowGroupRef group=NULL;
EventTypeSpec eventList[] = {
{kEventClassWindow, kEventWindowDrawContent},
{kEventClassWindow, kEventWindowBoundsChanged}};
EventHandlerUPP myHandlerUPP = NewEventHandlerUPP (MyWindowEventHandler);
CreateNewWindow( kOverlayWindowClass, kWindowNoUpdatesAttribute | kWindowNoActivatesAttribute | kWindowOpaqueForEventsAttribute , &bounds, &win );
InstallWindowEventHandler(win,
myHandlerUPP,
GetEventTypeCount(eventList),
eventList, win, NULL);
CreateWindowGroup(kWindowGroupAttrLayerTogether, &group);
SetWindowGroup(win, group);
SetWindowGroupLevel(group, CGShieldingWindowLevel());
ShowWindow( win );
ReleaseWindowGroup(group);
QDBeginCGContext( GetWindowPort( win ), &shieldContext);
CGContextClearRect(shieldContext, box);
if (shieldContext)
{
const char* sl="Draw Me";
CGContextSelectFont(shieldContext, "Lucida Grande", 24.0, kCGEncodingMacRoman);
CGContextSetShouldAntialias(shieldContext, true);
CGContextSetTextDrawingMode(shieldContext, kCGTextFill);
CGContextSetRGBFillColor(shieldContext, 0, 0, 0, 1);
CGContextShowTextAtPoint(shieldContext, 50, 50, sl, strlen(sl));
CGContextFlush(shieldContext);
QDEndCGContext( GetWindowPort( win ), &shieldContext);
}
}

This draws "Draw Me" to the screen, then flashes white. I've set a break point at my Event Event Handler but by that time it has already erased the area. It appears that in NSCarbonWindow's display method, its calling EraseWindowRegion() before it even calls me to redraw the window. Since its not waiting for me, returning noErr doesn't work. This seems like a bug.

Are there any workarounds? Anything I could be doing differently? I cannot redraw the window when it asks since I cannot keep the CGImageRef I am drawing around.
--


Sincerely,
Rosyna Keller
Technical Support/Holy Knight/Always needs a hug

Unsanity: Unsane Tools for Insanely Great People
---

Please include any previous correspondence in replies, it helps me remember what we were talking about. Thanks.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Prev by Date: Precompiled header woes
  • Next by Date: Re: clicking in NSMatrix.
  • Previous by thread: Re: Precompiled header woes
  • Next by thread: The emails of Oscar Morales: a bug somewhere?
  • Index(es):
    • Date
    • Thread