Platforms to show: All Mac Windows Linux Cross-Platform

/MacControls/HTMLViewer Mac/JavaScript callback test
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/JavaScript callback test
Project "JavaScript callback test.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 Output Inherits Label
ControlInstance Output Inherits Label
End Control
Control EditField1 Inherits TextArea
ControlInstance EditField1 Inherits TextArea
EventHandler Sub TextChange() UpdateTimer.mode=1 End EventHandler
End Control
Control UpdateTimer Inherits Timer
ControlInstance UpdateTimer Inherits Timer
EventHandler Sub Action() run End EventHandler
End Control
EventHandler Sub Open() wui=new MyFrameEvents web.InstallWebFrameLoadDelegateMBS wui if not me.Composite then MsgBox "This window must be composite!" end if run End EventHandler
Protected Sub run() web.LoadHTMLStringMBS EditField1.text,"text/html","","http://www.monkeybreadsoftware.de" End Sub
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 End EventHandler
Property callback As MyScriptCallback
End Class
Class MyFrameEvents Inherits WebFrameLoadDelegateMBS
EventHandler Function windowScriptObjectAvailable(windowScriptObject as WebScriptObjectMBS) As boolean // 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
End Class
Class MyScriptCallback Inherits WebScriptCallbackMBS
EventHandler Function Callback(Name as string) As variant System.DebugLog "Function: "+name Select case name case "MsgBox" MsgBox me.ArgumentValue(0) case "PrintDialog" call MainWindow.web.PrintDialogMBS case "SetText" MainWindow.Output.text=ArgumentValue(0) end Select 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...