Platforms to show: All Mac Windows Linux Cross-Platform

/MacControls/HTMLViewer Mac/WebFrameDelegate
Function:
Required plugins for this example: MBS MacBase Plugin, MBS MacControls Plugin, MBS Main Plugin, MBS MacCocoa Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacControls/HTMLViewer Mac/WebFrameDelegate
Project "WebFrameDelegate.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
Class MainWindow Inherits Window
Control Info Inherits Label
ControlInstance Info Inherits Label
End Control
Control web Inherits HTMLViewer
ControlInstance web Inherits HTMLViewer
End Control
Control List Inherits ListBox
ControlInstance List Inherits ListBox
End Control
EventHandler Sub Close() if wui<>nil then wui.w=nil end if End EventHandler
EventHandler Sub Open() wui=new MyFrameEvents wui.w=self web.InstallWebFrameLoadDelegateMBS wui if not me.Composite then MsgBox "This window must be composite!" end if End EventHandler
Property Protected wui As myFrameEvents
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
EventHandler Sub Open() if TargetMachO then // ok else MsgBox "This project works only as MachO target on Mac OS X." end if callback=new MyScriptCallback MainWindow.show // you need for WebScriptCallbackMBS a bit javascript which can call back MainWindow.web.LoadURL "http://www.christians-software.de/test.html" End EventHandler
Property callback As MyScriptCallback
End Class
Class MyFrameEvents Inherits WebFrameLoadDelegateMBS
EventHandler Sub Close() System.DebugLog "Close" End EventHandler
EventHandler Sub Open() System.DebugLog "Open" End EventHandler
EventHandler Function didCancelClientRedirectForFrame(frame as WebFrameMBS) As boolean w.List.AddRow "did cancel client redirection for frame "+hex(Frame.Handle) End EventHandler
EventHandler Function didChangeLocationWithinPageForFrame(frame as WebFrameMBS) As boolean w.List.AddRow "did chance location withing page for frame "+hex(Frame.Handle) End EventHandler
EventHandler Function didCommitLoadForFrame(frame as WebFrameMBS) As boolean w.List.AddRow "did commit load for frame "+hex(Frame.Handle) End EventHandler
EventHandler Function didFailLoadWithError(ErrorString as string, frame as WebFrameMBS) As boolean w.List.AddRow "did fail load for frame "+hex(Frame.Handle) End EventHandler
EventHandler Function didFailProvisionalLoadWithError(ErrorString as string, frame as WebFrameMBS) As boolean w.List.AddRow "did fail provisional load for frame "+hex(Frame.Handle) End EventHandler
EventHandler Function didFinishLoadForFrame(frame as WebFrameMBS) As boolean w.List.AddRow "did finish load for frame "+hex(Frame.Handle) End EventHandler
EventHandler Function didReceiveIcon(image as NSImageMBS, frame as WebFrameMBS) As boolean w.List.AddRow "did receive icon for frame "+hex(Frame.Handle) End EventHandler
EventHandler Function didReceiveServerRedirectForProvisionalLoadForFrame(frame as WebFrameMBS) As boolean w.List.AddRow "did receive server redirect for provisional load for frame "+hex(Frame.Handle) End EventHandler
EventHandler Function didReceiveTitle(title as string, frame as WebFrameMBS) As boolean w.List.AddRow "did receive title """+title+""" for frame "+hex(Frame.Handle) End EventHandler
EventHandler Function didStartProvisionalLoadForFrame(frame as WebFrameMBS) As boolean w.List.AddRow "did start provisional load for frame "+hex(Frame.Handle) End EventHandler
EventHandler Function willCloseFrame(frame as WebFrameMBS) As boolean w.List.AddRow "Will close frame "+hex(Frame.Handle) End EventHandler
EventHandler Function willPerformClientRedirectToURL(URL as String, delay as double, fireDate as Date, frame as WebFrameMBS) As boolean w.List.AddRow "will perform client redirect to url frame "+hex(Frame.Handle) End EventHandler
EventHandler Function windowScriptObjectAvailable(windowScriptObject as WebScriptObjectMBS) As boolean w.List.AddRow "window script object available" // Install an Object called "MyBrowser" on the javascript document object // Any function call inside will tricker callback event windowScriptObject.setWebScriptCallback "MyBrowser", app.callback End EventHandler
Property w As mainwindow
End Class
Class MyScriptCallback Inherits WebScriptCallbackMBS
EventHandler Function Callback(Name as string) As variant // Javascript called this function MsgBox "The function "+name+" was called"+EndOfLine+_ "Parameter 1: "+me.ArgumentValue(0)+EndOfLine+_ "Parameter 2: "+me.ArgumentValue(1)+EndOfLine+_ "Parameter 3: "+me.ArgumentValue(2) End EventHandler
End Class
End Project

See also:

The items on this page are in the following plugins: MBS MacControls Plugin.

Feedback: Report problem or ask question.

The biggest plugin in space...