mirror of
https://github.com/chenasraf/webview_cef.git
synced 2026-05-18 01:49:03 +00:00
[macos] fix mouse dragging
This commit is contained in:
@@ -105,17 +105,17 @@ void SimpleHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
|
||||
}
|
||||
|
||||
bool SimpleHandler::OnBeforePopup(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const CefString& target_url,
|
||||
const CefString& target_frame_name,
|
||||
WindowOpenDisposition target_disposition,
|
||||
bool user_gesture,
|
||||
const CefPopupFeatures& popupFeatures,
|
||||
CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient>& client,
|
||||
CefBrowserSettings& settings,
|
||||
CefRefPtr<CefDictionaryValue>& extra_info,
|
||||
bool* no_javascript_access) {
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const CefString& target_url,
|
||||
const CefString& target_frame_name,
|
||||
WindowOpenDisposition target_disposition,
|
||||
bool user_gesture,
|
||||
const CefPopupFeatures& popupFeatures,
|
||||
CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient>& client,
|
||||
CefBrowserSettings& settings,
|
||||
CefRefPtr<CefDictionaryValue>& extra_info,
|
||||
bool* no_javascript_access) {
|
||||
loadUrl(target_url);
|
||||
return true;
|
||||
}
|
||||
@@ -204,13 +204,16 @@ void SimpleHandler::cursorClick(int x, int y, bool up)
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleHandler::cursorMove(int x , int y)
|
||||
void SimpleHandler::cursorMove(int x , int y, bool dragging)
|
||||
{
|
||||
BrowserList::const_iterator it = browser_list_.begin();
|
||||
if (it != browser_list_.end()) {
|
||||
CefMouseEvent ev;
|
||||
ev.x = x;
|
||||
ev.y = y;
|
||||
if(dragging) {
|
||||
ev.modifiers = EVENTFLAG_LEFT_MOUSE_BUTTON;
|
||||
}
|
||||
(*it)->GetHost()->SendMouseMoveEvent(ev, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +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 cursorMove(int x, int y, bool dragging);
|
||||
void sendKeyEvent(CefKeyEvent ev);
|
||||
void loadUrl(std::string url);
|
||||
void goForward();
|
||||
|
||||
@@ -88,6 +88,15 @@ class WebViewController extends ValueNotifier<bool> {
|
||||
.invokeMethod('cursorMove', [position.dx, position.dy]);
|
||||
}
|
||||
|
||||
Future<void> _cursorDragging(Offset position) async {
|
||||
if (_isDisposed) {
|
||||
return;
|
||||
}
|
||||
assert(value);
|
||||
return _pluginChannel
|
||||
.invokeMethod('cursorDragging', [position.dx, position.dy]);
|
||||
}
|
||||
|
||||
Future<void> _cursorClickDown(Offset position) async {
|
||||
if (_isDisposed) {
|
||||
return;
|
||||
@@ -163,20 +172,16 @@ class WebViewState extends State<WebView> {
|
||||
child: SizeChangedLayoutNotifier(
|
||||
child: Listener(
|
||||
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) {
|
||||
print("move2");
|
||||
_controller._cursorMove(ev.localPosition);
|
||||
_controller._cursorDragging(ev.localPosition);
|
||||
},
|
||||
onPointerSignal: (signal) {
|
||||
if (signal is PointerScrollEvent) {
|
||||
|
||||
@@ -23,7 +23,7 @@ extern int64_t textureId;
|
||||
|
||||
+ (void) cursorClickDown: (int)x y:(int)y;
|
||||
|
||||
+ (void) cursorMove: (int)x y:(int)y;
|
||||
+ (void) cursorMove: (int)x y:(int)y dragging:(bool)dragging;
|
||||
|
||||
+ (void) sendScrollEvent:(int)x y:(int)y deltaX:(int)deltaX deltaY:(int)deltaY;
|
||||
|
||||
|
||||
@@ -196,8 +196,8 @@ int64_t textureId;
|
||||
handler.get()->cursorClick(x, y, false);
|
||||
}
|
||||
|
||||
+ (void)cursorMove:(int)x y:(int)y {
|
||||
handler.get()->cursorMove(x, y);
|
||||
+ (void)cursorMove:(int)x y:(int)y dragging:(bool)dragging {
|
||||
handler.get()->cursorMove(x, y, dragging);
|
||||
}
|
||||
|
||||
+ (void)sizeChanged:(float)dpi width:(int)width height:(int)height {
|
||||
|
||||
@@ -60,7 +60,14 @@
|
||||
NSArray<NSNumber *> *_arg = call.arguments;
|
||||
NSNumber *x = [_arg objectAtIndex:0];
|
||||
NSNumber *y = [_arg objectAtIndex:1];
|
||||
[CefWrapper cursorMove:[x intValue] y:[y intValue]];
|
||||
[CefWrapper cursorMove:[x intValue] y:[y intValue] dragging: false];
|
||||
result(nil);
|
||||
}
|
||||
else if([@"cursorDragging" 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] dragging: true];
|
||||
result(nil);
|
||||
}
|
||||
else if([@"setSize" isEqualToString:call.method]){
|
||||
|
||||
Reference in New Issue
Block a user