Platforms to show: All Mac Windows Linux Cross-Platform
/Mac64bit/WebKit2/WebView Resources
Required plugins for this example: MBS MacBase Plugin, MBS Mac64bit Plugin, MBS Main Plugin, MBS MacCocoa Plugin, MBS MacControls Plugin
Last modified Wed, 14th May 2024.
You find this example project in your MBS Xojo Plugin download as a Xojo project file within the examples folder: /Mac64bit/WebKit2/WebView Resources
Download this example: WebView Resources.zip
Project "WebView Resources.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
End EventHandler
End Class
Class MainWindow Inherits Window
Control browser Inherits WKWebViewControlMBS
ControlInstance browser Inherits WKWebViewControlMBS
EventHandler Sub Open()
Me.LoadURL "https://www.mbsplugins.de"
End EventHandler
EventHandler Sub decidePolicyForNavigationAction(navigationAction as WKNavigationActionMBS, decisionHandler as WKPolicyForNavigationActionDecisionHandlerMBS)
List.AddRow navigationAction.request.URL
// allow.
decisionHandler.Allow
End EventHandler
EventHandler Sub decidePolicyForNavigationResponse(navigationResponse as WKNavigationResponseMBS, decisionHandler as WKPolicyForNavigationResponseDecisionHandlerMBS)
Dim response As NSURLResponseMBS = navigationResponse.response
List.AddRow response.URL, If(navigationResponse.isForMainFrame, "yes", "no"), response.MIMEType, response.suggestedFilename
// allow.
decisionHandler.Allow
End EventHandler
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
EventHandler Sub Open()
#If Target64Bit Then
Title = "WebKit 2 with 64-bit"
#else
Title = "WebKit 1 with 32-bit"
#endif
End EventHandler
Function FindFile(name as string) As FolderItem
// Look for file in parent folders from executable on
dim parent as FolderItem = app.ExecutableFile.Parent
while parent<>Nil
dim file as FolderItem = parent.Child(name)
if file<>Nil and file.Exists then
Return file
end if
parent = parent.Parent
wend
End Function
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Sign
End Sign
End Project
See also:
Download this example: WebView Resources.zip
The items on this page are in the following plugins: MBS Mac64bit Plugin.