Add ‘visible’ property to OakHTMLOutputView

This can be observed to learn when the view is hidden, either because the window it is in closes or when it is removed from its superview.
This commit is contained in:
Allan Odgaard
2016-09-27 17:06:49 +02:00
parent 09534b7ffc
commit 010bb72375
2 changed files with 15 additions and 0 deletions

View File

@@ -7,6 +7,7 @@
@property (nonatomic) NSUUID* commandIdentifier; // UUID from initial load request
@property (nonatomic, getter = isRunningCommand, readonly) BOOL runningCommand;
@property (nonatomic, getter = isVisible, readonly) BOOL visible;
// Read-only access to the webview is given to allow reading page title, etc.
@property (nonatomic, readonly) WebView* webView;

View File

@@ -15,6 +15,7 @@
@property (nonatomic) HOAutoScroll* autoScrollHelper;
@property (nonatomic) std::map<std::string, std::string> environment;
@property (nonatomic) NSRect pendingVisibleRect;
@property (nonatomic, getter = isVisible) BOOL visible;
@end
@implementation OakHTMLOutputView
@@ -100,6 +101,19 @@
return self.webView.mainFrameTitle;
}
- (void)viewDidMoveToWindow
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowWillCloseNotification object:nil];
if(self.window)
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowWillClose:) name:NSWindowWillCloseNotification object:self.window];
self.visible = self.window ? YES : NO;
}
- (void)windowWillClose:(NSNotification*)aNotification
{
self.visible = NO;
}
// =======================
// = Frame Load Delegate =
// =======================