Cocoa webview embed event in QT application

I intend to replace webkit QT with my own Webkit OSX in a QT-based application, which I did right now by creating a QT control inherited from QMacCocoaViewContainer and injecting cocoa web view into it. It may display the page correctly, but cocoa webview cannot receive the mouse move event, therefore the js / css hover effect cannot be shown. I tried comparing it with the cocoa native application and found that the cocoa web view could receive NSMouseMovedNotifcation from the notification center in the cocoa native application, but the QT application creates its own event loop and dispatches the event with its own strategy. notification is not accepted.

Who can tell me how to fix this? Any comments are greatly appreciated.

QTWebView(QWidget *pparent): QMacCocoaViewContainer(0, pparent) { ... xwebview = [[WebView alloc] init]; setCocoaView(xwebview); NSString *urldefault = @"http://www.google.com"; [[xwebview mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urldefault]]]; ... } 
0
source share
1 answer

I had a similar problem and solved it by implementing the macEvent function (EventHandlerCallerRef, EventRef). Create an NSEvent from eventRef

 NSEvent* nsEvent = [NSEvent eventWithEventRef:event]; 

If the event is a MouseMoved event, send the mouseMoved: event to the NSView, where NSView (NSView *) winId ().

I hope this helps

0
source

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


All Articles