I am trying to implement a Pythonista API for WKWebView. All credit for all ObjC code so far goes to @mithrendal.
For the load policy decision, I would need to invoke the decision handler with a single integer parameter. Repurposing @JonB code from the multipeer project I arrived at the following, but get an exception stating that the handler was never called.
Any ideas? Thanks.
class _block_descriptor (Structure):
_fields_ = [('reserved', c_ulong), ('size', c_ulong), ('copy_helper', c_void_p), ('dispose_helper', c_void_p), ('signature', c_char_p)]
InvokeFuncType = ctypes.CFUNCTYPE(None, *[c_void_p, ctypes.c_int])
class _block_literal(Structure):
_fields_ = [('isa', c_void_p), ('flags', c_int), ('reserved', c_int), ('invoke', InvokeFuncType), ('descriptor', _block_descriptor)]
def webView_decidePolicyForNavigationAction_decisionHandler_(_self, _cmd, _webview, _navigation_action, _decision_handler):
decision_handler = ObjCInstance(_decision_handler)
retain_global(decision_handler)
blk = _block_literal.from_address(_decision_handler)
blk.invoke(decision_handler, 1)