objective c - NSView containing NSOpenGLView doesn't redraw after a subview is removed -
i have mac os x (10.9) application custom nsview main nswindow's contentview
property. thing custom view override drawrect:
it's transparent. transparency required nsopenglview visible (see below):
/* transparent nsview subclass */ - (void)drawrect:(nsrect)dirtyrect { nslog(@"drawing rect"); [[nscolor clearcolor] set]; nsrectfillusingoperation(dirtyrect, nscompositeclear); }
the contentview
has nsopenglview subview, surface order set -1 (it's 'below' main nswindow, transparent):
/* nsopenglview subclass: */ glint order = -1; [self.openglcontext setvalues:&order forparameter:nsopenglcpsurfaceorder];
i instantiate webview , place subview of custom view:
_webview = [[webview alloc] initwithframe:frame]; [_webview setmaintainsbackforwardlist:no]; [_webview settranslatesautoresizingmaskintoconstraints:no]; [_webview setdrawsbackground:no]; [_window.contentview addsubview:_webview];
the webview small box in window (on top of nsopenglview) used login service. once login happens should disappear, showing nsopenglview.
here's problem: when call [_webview removefromsuperview];
contentview
not redraw; therefore, webview still drawn on screen (although not responsive mouse or keyboard). if use mouse resize window in, contentview
redraws (i see message in logs) , webview's content disappears. also, if don't add nsopenglview subview, webview goes away should.
shouldn't contentview
fire drawrect
after subview removed? when used setneedsdisplay:
or setneedslayout:
after removing webview contentview
still didn't redraw.
apple's advice these days use core animation layers put normal views on top of opengl views.
i suspect content view has redrawn itself. draws clear. you're seeing opengl surface behind it. nearly-raw-vram nature of opengl surfaces may mean web view drawn on top of modified contents of surface. so, recommend force opengl view redraw itself. if draws in -drawrect:
, should enough send -setneedsdisplay:
. if rendering outside of -drawrect:
manually making context current, issuing rendering commands, , calling -flushbuffer
, you'll need that.
Comments
Post a Comment