I am creating an application which have a kiosk web browser as one of its features.
The web browser is in a NSWindowController and a strange thing is happening: when the NSWindowController is loaded i set the WebView url to a default one and start loading the page. Everything loads fine etc, but i can't interact with the WebView (ie. click on a link in the loaded page) before i have clicked anywhere on the window. After that everything is working fine. Looks like the window is missing 'focus' and after clicking on the window it gets focus and i see the cursor changing when hovering over links etc...
This is not an issue when i don't use [[self.window contentView] enterFullScreenMode:[NSScreen mainScreen] withOptions:nil];
There are couple of buttons in the window too, but they just work on the first click without the focusing.
Anyway here is the code that do most of the job:
NSApplicationPresentationOptions options =
NSApplicationPresentationHideMenuBar|NSApplicationPresentationHideDock|
NSApplicationPresentationDisableHideApplication|
NSApplicationPresentationDisableProcessSwitching|
NSApplicationPresentationDisableAppleMenu| NSApplicationPresentationDisableForceQuit;
[NSApp setPresentationOptions:options];
[[self.window contentView] enterFullScreenMode:[NSScreen mainScreen] withOptions:nil];
[self.webView setFrameLoadDelegate:self];
[self.webView setPolicyDelegate:self];
NSString *url = [[NSString alloc] initWithString:@"https://www.google.com"];
[[self.webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
I assume that your webView is not the first responder before you click on it. You can change this by using
[[self window] makeFirstResponder:webView];
Also [self.window makeKeyAndOrderFront:self];
or [NSApp activateIgnoringOtherApps:YES];
could make a change dependent on the situation. If this will not help you may need to make the call with delay dependent when its initially used.
[self performSelector:@selector(myDelayedActivateFunction) withObject:nil afterDelay:0.0];