Control browser Inherits WKWebViewControlMBS
ControlInstance browser Inherits WKWebViewControlMBS
EventHandler Sub JavaScriptEvaluated(JavaScript as String, Result as Variant, Error as NSErrorMBS, Tag as String)
List.AddRow CurrentMethodName
List.AddRow "JavaScript", JavaScript
if Error = nil then
List.AddRow "Error", "none"
else
List.AddRow "Error", Error.LocalizedDescription
end if
List.AddRow "Tag", Tag
List.AddRow ""
List.ScrollPosition = List.ListCount
MsgBox "JavaScript result: "+result.StringValue
End EventHandler
EventHandler Sub Open()
Dim f As FolderItem = FindFile("test.html")
dim b as BinaryStream = BinaryStream.Open(f)
dim s as string = b.Read(B.Length, encodings.UTF8)
me.LoadHTML s
End EventHandler
EventHandler Sub decidePolicyForNavigationAction(navigationAction as WKNavigationActionMBS, decisionHandler as WKPolicyForNavigationDecisionHandlerMBS)
List.AddRow CurrentMethodName
List.AddRow "URL", navigationAction.request.URL
List.AddRow "NavigationType", navigationAction.navigationType.ToString
List.AddRow "modifierFlags", navigationAction.modifierFlags.ToString
List.AddRow "buttonNumber", navigationAction.buttonNumber.ToString
List.AddRow "newWindow", navigationAction.newWindow.ToString
List.AddRow "shouldPerformDownload", navigationAction.shouldPerformDownload.ToString
List.AddRow ""
List.ScrollPosition = List.ListCount
// either cancel, download or allow
decisionHandler.Allow
End EventHandler
EventHandler Sub didCloseContextualMenu(menu as NSMenuMBS, NSEvent as NSEventMBS)
List.AddRow CurrentMethodName
End EventHandler
EventHandler Sub didCommitNavigation(navigation as WKNavigationMBS)
List.AddRow CurrentMethodName
End EventHandler
EventHandler Sub didFailNavigation(navigation as WKNavigationMBS, Error as NSErrorMBS)
List.AddRow CurrentMethodName
if error <> nil then
List.AddRow "error", Error.LocalizedDescription
end if
End EventHandler
EventHandler Sub didFailProvisionalNavigation(navigation as WKNavigationMBS, Error as NSErrorMBS)
List.AddRow CurrentMethodName
if error <> nil then
List.AddRow "error", Error.LocalizedDescription
end if
End EventHandler
EventHandler Sub didFinishNavigation(navigation as WKNavigationMBS)
List.AddRow CurrentMethodName
End EventHandler
EventHandler Sub didReceiveScriptMessage(Body as Variant, name as String)
MsgBox name+EndOfLine+body.StringValue
End EventHandler
EventHandler Sub didReceiveServerRedirectForProvisionalNavigation(navigation as WKNavigationMBS)
List.AddRow CurrentMethodName
End EventHandler
EventHandler Sub didStartProvisionalNavigation(navigation as WKNavigationMBS)
List.AddRow CurrentMethodName
End EventHandler
EventHandler Sub runJavaScriptAlertPanel(initiatedByFrame as WKFrameInfoMBS, message as String)
List.AddRow CurrentMethodName
List.AddRow "Message", Message
List.AddRow ""
List.ScrollPosition = List.ListCount
MsgBox message
End EventHandler
EventHandler Function runJavaScriptConfirmPanel(initiatedByFrame as WKFrameInfoMBS, message as String) As boolean
List.AddRow CurrentMethodName
List.AddRow "Message", Message
List.AddRow ""
List.ScrollPosition = List.ListCount
Dim d as New MessageDialog //declare the MessageDialog object
d.icon=MessageDialog.GraphicCaution //display warning icon
d.ActionButton.Caption="Confirm"
d.CancelButton.Visible=True //show the Cancel button
d.Message=message
Dim b as MessageDialogButton = d.ShowModal //display the dialog
Select Case b //determine which button was pressed.
Case d.ActionButton
//user pressed Confirm
Return true
End select
End EventHandler
EventHandler Function runJavaScriptTextInputPanel(initiatedByFrame as WKFrameInfoMBS, prompt as String, defaultText as String) As String
List.AddRow CurrentMethodName
List.AddRow "prompt", prompt
List.AddRow "defaultText", defaultText
List.AddRow ""
List.ScrollPosition = List.ListCount
dim r as string
dim d as new InputDialog
d.Message.Text = prompt
d.InputField.Text = defaultText
d.ShowModal
if d.ok then
r = d.InputField.Text
end if
d.close
Return r
End EventHandler
EventHandler Sub willShowContextualMenu(menu as NSMenuMBS, NSEvent as NSEventMBS)
List.AddRow CurrentMethodName
// remove all
'menu.removeAllItems
// subclass to catch event (or use addHandler)
Dim m As New MyNSMenuItemMBS
m.CreateMenuItem
m.Title = "Hello World"
// no subclass for separator needed
Dim s As New NSMenuItemMBS
s.CreateSeparator
// add our items
menu.addItem s
menu.addItem m
// make sure Xojo objects stay alive for some time
LastContextMenuItem = m
LastContextMenu = menu
End EventHandler
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control TryButton Inherits BevelButton
ControlInstance TryButton Inherits BevelButton
EventHandler Sub Action()
browser.EvaluateJavaScript("window.webkit.messageHandlers.test.postMessage('Hello');")
End EventHandler
End Control