mirror of
https://github.com/chenasraf/webview_cef.git
synced 2026-05-18 01:49:03 +00:00
[macos] send mouse move events to cef
This commit is contained in:
@@ -204,6 +204,17 @@ void SimpleHandler::cursorClick(int x, int y, bool up)
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleHandler::cursorMove(int x , int y)
|
||||
{
|
||||
BrowserList::const_iterator it = browser_list_.begin();
|
||||
if (it != browser_list_.end()) {
|
||||
CefMouseEvent ev;
|
||||
ev.x = x;
|
||||
ev.y = y;
|
||||
(*it)->GetHost()->SendMouseMoveEvent(ev, false);
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleHandler::sendKeyEvent(CefKeyEvent ev)
|
||||
{
|
||||
BrowserList::const_iterator it = browser_list_.begin();
|
||||
|
||||
@@ -78,6 +78,7 @@ public:
|
||||
void sendScrollEvent(int x, int y, int deltaX, int deltaY);
|
||||
void changeSize(float a_dpi, int width, int height);
|
||||
void cursorClick(int x, int y, bool up);
|
||||
void cursorMove(int x, int y);
|
||||
void sendKeyEvent(CefKeyEvent ev);
|
||||
void loadUrl(std::string url);
|
||||
void goForward();
|
||||
|
||||
@@ -79,13 +79,13 @@ class WebViewController extends ValueNotifier<bool> {
|
||||
}
|
||||
|
||||
/// Moves the virtual cursor to [position].
|
||||
Future<void> _setCursorPos(Offset position) async {
|
||||
Future<void> _cursorMove(Offset position) async {
|
||||
if (_isDisposed) {
|
||||
return;
|
||||
}
|
||||
assert(value);
|
||||
return _pluginChannel
|
||||
.invokeMethod('setCursorPos', [position.dx, position.dy]);
|
||||
.invokeMethod('cursorMove', [position.dx, position.dy]);
|
||||
}
|
||||
|
||||
Future<void> _cursorClickDown(Offset position) async {
|
||||
@@ -162,15 +162,21 @@ class WebViewState extends State<WebView> {
|
||||
},
|
||||
child: SizeChangedLayoutNotifier(
|
||||
child: Listener(
|
||||
onPointerHover: (ev) {},
|
||||
onPointerHover: (ev) {
|
||||
print("move1");
|
||||
_controller._cursorMove(ev.localPosition);
|
||||
},
|
||||
onPointerDown: (ev) {
|
||||
print("down");
|
||||
_controller._cursorClickDown(ev.localPosition);
|
||||
},
|
||||
onPointerUp: (ev) {
|
||||
print("up");
|
||||
_controller._cursorClickUp(ev.localPosition);
|
||||
},
|
||||
onPointerMove: (ev) {
|
||||
// _controller._setCursorPos(ev.localPosition);
|
||||
print("move2");
|
||||
_controller._cursorMove(ev.localPosition);
|
||||
},
|
||||
onPointerSignal: (signal) {
|
||||
if (signal is PointerScrollEvent) {
|
||||
@@ -191,7 +197,8 @@ class WebViewState extends State<WebView> {
|
||||
final box = _key.currentContext?.findRenderObject() as RenderBox?;
|
||||
if (box != null) {
|
||||
await _controller.ready;
|
||||
unawaited(_controller._setSize(dpi, Size(box.size.width, box.size.height)));
|
||||
unawaited(
|
||||
_controller._setSize(dpi, Size(box.size.width, box.size.height)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ extern int64_t textureId;
|
||||
|
||||
+ (void) cursorClickDown: (int)x y:(int)y;
|
||||
|
||||
+ (void) cursorMove: (int)x y:(int)y;
|
||||
|
||||
+ (void) sendScrollEvent:(int)x y:(int)y deltaX:(int)deltaX deltaY:(int)deltaY;
|
||||
|
||||
+ (void) sizeChanged: (float)dpi width:(int)width height:(int)height;
|
||||
|
||||
@@ -196,6 +196,10 @@ int64_t textureId;
|
||||
handler.get()->cursorClick(x, y, false);
|
||||
}
|
||||
|
||||
+ (void)cursorMove:(int)x y:(int)y {
|
||||
handler.get()->cursorMove(x, y);
|
||||
}
|
||||
|
||||
+ (void)sizeChanged:(float)dpi width:(int)width height:(int)height {
|
||||
handler.get()->changeSize(dpi, width, height);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,13 @@
|
||||
[CefWrapper cursorClickDown:[x intValue] y:[y intValue]];
|
||||
result(nil);
|
||||
}
|
||||
else if([@"cursorMove" isEqualToString:call.method]){
|
||||
NSArray<NSNumber *> *_arg = call.arguments;
|
||||
NSNumber *x = [_arg objectAtIndex:0];
|
||||
NSNumber *y = [_arg objectAtIndex:1];
|
||||
[CefWrapper cursorMove:[x intValue] y:[y intValue]];
|
||||
result(nil);
|
||||
}
|
||||
else if([@"setSize" isEqualToString:call.method]){
|
||||
NSArray<NSNumber *> *_arg = call.arguments;
|
||||
NSNumber *dpi = [_arg objectAtIndex:0];
|
||||
|
||||
Reference in New Issue
Block a user