parent
a42b0e4dfd
commit
a7cda8d5b6
|
@ -20,8 +20,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
|
|||
mediaPlaybackRequiresUserGesture: false,
|
||||
allowsInlineMediaPlayback: true,
|
||||
iframeAllow: "camera; microphone",
|
||||
iframeAllowFullscreen: true
|
||||
);
|
||||
iframeAllowFullscreen: true);
|
||||
|
||||
PullToRefreshController? pullToRefreshController;
|
||||
|
||||
|
@ -45,7 +44,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
|
|||
await webViewController?.clearFocus();
|
||||
})
|
||||
],
|
||||
settings: ContextMenuSettings(hideDefaultSystemContextMenuItems: false),
|
||||
settings: ContextMenuSettings(hideDefaultSystemContextMenuItems: true),
|
||||
onCreateContextMenu: (hitTestResult) async {
|
||||
print("onCreateContextMenu");
|
||||
print(hitTestResult.extra);
|
||||
|
@ -62,7 +61,9 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
|
|||
contextMenuItemClicked.title);
|
||||
});
|
||||
|
||||
pullToRefreshController = kIsWeb || ![TargetPlatform.iOS, TargetPlatform.android].contains(defaultTargetPlatform)
|
||||
pullToRefreshController = kIsWeb ||
|
||||
![TargetPlatform.iOS, TargetPlatform.android]
|
||||
.contains(defaultTargetPlatform)
|
||||
? null
|
||||
: PullToRefreshController(
|
||||
settings: PullToRefreshSettings(
|
||||
|
@ -120,7 +121,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
|
|||
// initialFile: "assets/index.html",
|
||||
initialUserScripts: UnmodifiableListView<UserScript>([]),
|
||||
initialSettings: settings,
|
||||
// contextMenu: contextMenu,
|
||||
contextMenu: contextMenu,
|
||||
pullToRefreshController: pullToRefreshController,
|
||||
onWebViewCreated: (controller) async {
|
||||
webViewController = controller;
|
||||
|
|
|
@ -239,8 +239,25 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
|
|||
return super.hitTest(point, with: event)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@available(iOS 13.0, *)
|
||||
public override func buildMenu(with builder: UIMenuBuilder) {
|
||||
if #available(iOS 16.0, *) {
|
||||
if let menu = contextMenu {
|
||||
let contextMenuSettings = ContextMenuSettings()
|
||||
if let contextMenuSettingsMap = menu["settings"] as? [String: Any?] {
|
||||
let _ = contextMenuSettings.parse(settings: contextMenuSettingsMap)
|
||||
if contextMenuSettings.hideDefaultSystemContextMenuItems {
|
||||
builder.remove(menu: .lookup)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
super.buildMenu(with: builder)
|
||||
}
|
||||
|
||||
public override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
|
||||
if let _ = sender as? UIMenuController {
|
||||
if self.settings?.disableContextMenu == true {
|
||||
if !onCreateContextMenuEventTriggeredWhenMenuDisabled {
|
||||
// workaround to trigger onCreateContextMenu event as the same on Android
|
||||
|
@ -267,7 +284,6 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
|
|||
let id = action.description.compactMap({ $0.asciiValue?.description }).joined()
|
||||
self.channelDelegate?.onContextMenuActionItemClicked(id: id, title: action.description)
|
||||
}
|
||||
}
|
||||
|
||||
return super.canPerformAction(action, withSender: sender)
|
||||
}
|
||||
|
@ -613,6 +629,10 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
|
|||
|
||||
let hitTestResult = HitTestResult(type: .unknownType, extra: nil)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if let lastLongPressTouhLocation = lastLongPressTouchPoint {
|
||||
if configuration.preferences.javaScriptEnabled {
|
||||
self.evaluateJavaScript("window.\(JAVASCRIPT_BRIDGE_NAME)._findElementsAtPoint(\(lastLongPressTouhLocation.x),\(lastLongPressTouhLocation.y))", completionHandler: {(value, error) in
|
||||
|
|
Loading…
Reference in New Issue