webView:decisionListener not working for iframe
up vote
0
down vote
favorite
I use cocoa calls to set an webView:decidePolicyForNavigationAction:request:frame:decisionListener:
By this callback, I can decode about what to do with the links some user clicked. But sadly, if there is some iframe inside, I do not get the callback for the links inside of the iframe.
I tried using findFrameNamed: function to get the webFrame of the iframe (seem to work) and then getting the underlying webView to set the decisionListener there, but it does not fire.
Any hints?
PS. I use PureBasic, calling the Cocoa functions manually. So I can only add my PB code, if this is of any help:
Global appDelegate = CocoaMessage(0, CocoaMessage(0, 0, "NSApplication sharedApplication"), "delegate")
Global delegateClass = CocoaMessage(0, appDelegate, "class")
ProcedureC PolicyDecisionMaker(obj, sel, webView, actionInformation, request, frameName, listener)
; handle all links like it is _blank target. We do not want something else in regify client.
Protected URL = CocoaMessage(0, request, "URL")
Protected URLText.s = PeekS(CocoaMessage(0, CocoaMessage(0, URL, "absoluteString"), "UTF8String"), -1, #PB_UTF8)
Debug "URL: " + URLText.s
EndProcedure
class_addMethod(delegateClass,
sel_registerName("webView:decidePolicyForNavigationAction:request:frame:decisionListener:"),
@PolicyDecisionMaker(),
"v@:@@@@@")
Procedure.i SetMacWebgadgetTargetSupport(WebgadgetID.i, iFrameName.s = "")
If iFrameName.s = ""
CocoaMessage(0, GadgetID(WebgadgetID.i), "setPolicyDelegate:", appDelegate)
ProcedureReturn #True
EndIf
Protected macMainFrame = CocoaMessage(0, GadgetID(WebgadgetID), "mainFrame")
Protected maciFrameView = CocoaMessage(0, macMainFrame, "findFrameNamed:$", @iFrameName.s); get iframe
If maciFrameView <> 0
; Set appDelegate on the given iFrame
Protected macWebView = CocoaMessage(0, maciFrameView, "webView") ; get webView object
CocoaMessage(0, macWebView, "setPolicyDelegate:", appDelegate)
ProcedureReturn #True
EndIf
ProcedureReturn #False
EndProcedure
The above works fine on normal HTML (eg file://somefile.html). But it fails for iFrame with links inside.
macos cocoa iframe webkit
add a comment |
up vote
0
down vote
favorite
I use cocoa calls to set an webView:decidePolicyForNavigationAction:request:frame:decisionListener:
By this callback, I can decode about what to do with the links some user clicked. But sadly, if there is some iframe inside, I do not get the callback for the links inside of the iframe.
I tried using findFrameNamed: function to get the webFrame of the iframe (seem to work) and then getting the underlying webView to set the decisionListener there, but it does not fire.
Any hints?
PS. I use PureBasic, calling the Cocoa functions manually. So I can only add my PB code, if this is of any help:
Global appDelegate = CocoaMessage(0, CocoaMessage(0, 0, "NSApplication sharedApplication"), "delegate")
Global delegateClass = CocoaMessage(0, appDelegate, "class")
ProcedureC PolicyDecisionMaker(obj, sel, webView, actionInformation, request, frameName, listener)
; handle all links like it is _blank target. We do not want something else in regify client.
Protected URL = CocoaMessage(0, request, "URL")
Protected URLText.s = PeekS(CocoaMessage(0, CocoaMessage(0, URL, "absoluteString"), "UTF8String"), -1, #PB_UTF8)
Debug "URL: " + URLText.s
EndProcedure
class_addMethod(delegateClass,
sel_registerName("webView:decidePolicyForNavigationAction:request:frame:decisionListener:"),
@PolicyDecisionMaker(),
"v@:@@@@@")
Procedure.i SetMacWebgadgetTargetSupport(WebgadgetID.i, iFrameName.s = "")
If iFrameName.s = ""
CocoaMessage(0, GadgetID(WebgadgetID.i), "setPolicyDelegate:", appDelegate)
ProcedureReturn #True
EndIf
Protected macMainFrame = CocoaMessage(0, GadgetID(WebgadgetID), "mainFrame")
Protected maciFrameView = CocoaMessage(0, macMainFrame, "findFrameNamed:$", @iFrameName.s); get iframe
If maciFrameView <> 0
; Set appDelegate on the given iFrame
Protected macWebView = CocoaMessage(0, maciFrameView, "webView") ; get webView object
CocoaMessage(0, macWebView, "setPolicyDelegate:", appDelegate)
ProcedureReturn #True
EndIf
ProcedureReturn #False
EndProcedure
The above works fine on normal HTML (eg file://somefile.html). But it fails for iFrame with links inside.
macos cocoa iframe webkit
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I use cocoa calls to set an webView:decidePolicyForNavigationAction:request:frame:decisionListener:
By this callback, I can decode about what to do with the links some user clicked. But sadly, if there is some iframe inside, I do not get the callback for the links inside of the iframe.
I tried using findFrameNamed: function to get the webFrame of the iframe (seem to work) and then getting the underlying webView to set the decisionListener there, but it does not fire.
Any hints?
PS. I use PureBasic, calling the Cocoa functions manually. So I can only add my PB code, if this is of any help:
Global appDelegate = CocoaMessage(0, CocoaMessage(0, 0, "NSApplication sharedApplication"), "delegate")
Global delegateClass = CocoaMessage(0, appDelegate, "class")
ProcedureC PolicyDecisionMaker(obj, sel, webView, actionInformation, request, frameName, listener)
; handle all links like it is _blank target. We do not want something else in regify client.
Protected URL = CocoaMessage(0, request, "URL")
Protected URLText.s = PeekS(CocoaMessage(0, CocoaMessage(0, URL, "absoluteString"), "UTF8String"), -1, #PB_UTF8)
Debug "URL: " + URLText.s
EndProcedure
class_addMethod(delegateClass,
sel_registerName("webView:decidePolicyForNavigationAction:request:frame:decisionListener:"),
@PolicyDecisionMaker(),
"v@:@@@@@")
Procedure.i SetMacWebgadgetTargetSupport(WebgadgetID.i, iFrameName.s = "")
If iFrameName.s = ""
CocoaMessage(0, GadgetID(WebgadgetID.i), "setPolicyDelegate:", appDelegate)
ProcedureReturn #True
EndIf
Protected macMainFrame = CocoaMessage(0, GadgetID(WebgadgetID), "mainFrame")
Protected maciFrameView = CocoaMessage(0, macMainFrame, "findFrameNamed:$", @iFrameName.s); get iframe
If maciFrameView <> 0
; Set appDelegate on the given iFrame
Protected macWebView = CocoaMessage(0, maciFrameView, "webView") ; get webView object
CocoaMessage(0, macWebView, "setPolicyDelegate:", appDelegate)
ProcedureReturn #True
EndIf
ProcedureReturn #False
EndProcedure
The above works fine on normal HTML (eg file://somefile.html). But it fails for iFrame with links inside.
macos cocoa iframe webkit
I use cocoa calls to set an webView:decidePolicyForNavigationAction:request:frame:decisionListener:
By this callback, I can decode about what to do with the links some user clicked. But sadly, if there is some iframe inside, I do not get the callback for the links inside of the iframe.
I tried using findFrameNamed: function to get the webFrame of the iframe (seem to work) and then getting the underlying webView to set the decisionListener there, but it does not fire.
Any hints?
PS. I use PureBasic, calling the Cocoa functions manually. So I can only add my PB code, if this is of any help:
Global appDelegate = CocoaMessage(0, CocoaMessage(0, 0, "NSApplication sharedApplication"), "delegate")
Global delegateClass = CocoaMessage(0, appDelegate, "class")
ProcedureC PolicyDecisionMaker(obj, sel, webView, actionInformation, request, frameName, listener)
; handle all links like it is _blank target. We do not want something else in regify client.
Protected URL = CocoaMessage(0, request, "URL")
Protected URLText.s = PeekS(CocoaMessage(0, CocoaMessage(0, URL, "absoluteString"), "UTF8String"), -1, #PB_UTF8)
Debug "URL: " + URLText.s
EndProcedure
class_addMethod(delegateClass,
sel_registerName("webView:decidePolicyForNavigationAction:request:frame:decisionListener:"),
@PolicyDecisionMaker(),
"v@:@@@@@")
Procedure.i SetMacWebgadgetTargetSupport(WebgadgetID.i, iFrameName.s = "")
If iFrameName.s = ""
CocoaMessage(0, GadgetID(WebgadgetID.i), "setPolicyDelegate:", appDelegate)
ProcedureReturn #True
EndIf
Protected macMainFrame = CocoaMessage(0, GadgetID(WebgadgetID), "mainFrame")
Protected maciFrameView = CocoaMessage(0, macMainFrame, "findFrameNamed:$", @iFrameName.s); get iframe
If maciFrameView <> 0
; Set appDelegate on the given iFrame
Protected macWebView = CocoaMessage(0, maciFrameView, "webView") ; get webView object
CocoaMessage(0, macWebView, "setPolicyDelegate:", appDelegate)
ProcedureReturn #True
EndIf
ProcedureReturn #False
EndProcedure
The above works fine on normal HTML (eg file://somefile.html). But it fails for iFrame with links inside.
macos cocoa iframe webkit
macos cocoa iframe webkit
asked 15 hours ago
Volker Schmid
12
12
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53265978%2fwebviewdecisionlistener-not-working-for-iframe%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password