When a WebView is added to a specific view in NSWindow :: hover stops working. How can i fix this?

If I create a WebView and add it to an NSThemeFrame as follows:

Let the window be an instance of NSWindow, which I add to:

NSView * themeFrame = window.contentView; [themeFrame.superview addSubview:myWebView]; 

Then any: tagging elements on the page I am loading no longer works. However: hover appears on mouseDown / mouseUp. Perhaps this is an update issue. I tried calling [myWebView setNeedsDisplay: YES] in mouseMoved: but no luck.

Is there anything special about the contentView? I tried the same with NSView and overloaded its mouseMoved method: when calling setNeedsDisplay and the mouseView handler. Is there anything special: hover over?

Any ideas or take-offs are welcome!

I may have the same problem as Cocoa WebView on os X, without triggering mouseover events, without clicking and holding the left mouse button , but there is no answer.

+4
source share
1 answer

I had a similar problem, and after debugging and reading the WebKit source, I found a solution. The most important part is presented to the WebHTMLView class , in particular, the method -[WebHTMLView _updateMouseoverWithEvent:] . There, check to see if the viewport is a key window and, of course, my window was not key, although I call it makeKeyWindow .

My window was a child window of the document window, and to solve the problem of freezing, I created a subclass of NSWindow and redid isKeyWindow as follows:

 - (BOOL)isKeyWindow { return [super isKeyWindow] || [[self parentWindow] isKeyWindow]; } 

This did the job of freezing in WebView in my document window.

+1
source

Source: https://habr.com/ru/post/1485730/


All Articles