Platforms to show: All Mac Windows Linux Cross-Platform

/MacControls/HTMLViewer Mac/HTMLViewer Extensions
Function:
Required plugins for this example: MBS MacBase Plugin, MBS Main Plugin, MBS MacCocoa Plugin, MBS MacControls Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacControls/HTMLViewer Mac/HTMLViewer Extensions
Project "HTMLViewer Extensions.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open() if TargetMachO then // ok else MsgBox "This project works only as MachO target on Mac OS X." end if End EventHandler
End Class
Class Window1 Inherits Window
Control HTML Inherits HTMLViewer
ControlInstance HTML Inherits HTMLViewer
EventHandler Sub DocumentComplete(URL as String) ProgressBar1.Value=100 timer1.Mode=0 End EventHandler
EventHandler Sub Open() Slider1.Value=html.TextSizeMultiplierMBS*100.0 End EventHandler
End Control
Control EditField1 Inherits TextField
ControlInstance EditField1 Inherits TextField
EventHandler Function KeyDown(Key As String) As Boolean if asc(key)=13 or asc(key)=3 then HTML.LoadURL me.text Timer1.mode=2 ClearFocus return true end if End EventHandler
End Control
Control TabPanel1 Inherits TabPanel
ControlInstance TabPanel1 Inherits TabPanel
End Control
Control mimetype Inherits TextField
ControlInstance mimetype Inherits TextField
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() if html.CanShowMIMETypeAsHTMLMBS(mimetype.text) then MsgBox "CanShowMIMETypeAsHTMLMBS: yes" else MsgBox "CanShowMIMETypeAsHTMLMBS: no" end if End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() if html.CanShowMIMETypeMBS(mimetype.text) then MsgBox "CanShowMIMETypeMBS: yes" else MsgBox "CanShowMIMETypeMBS: no" end if End EventHandler
End Control
Control GroupName Inherits TextField
ControlInstance GroupName Inherits TextField
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action() html.GroupNameMBS=groupname.text End EventHandler
End Control
Control PushButton4 Inherits PushButton
ControlInstance PushButton4 Inherits PushButton
EventHandler Sub Action() groupname.text=html.GroupNameMBS End EventHandler
End Control
Control prefid Inherits TextField
ControlInstance prefid Inherits TextField
End Control
Control StaticText3 Inherits Label
ControlInstance StaticText3 Inherits Label
End Control
Control PushButton5 Inherits PushButton
ControlInstance PushButton5 Inherits PushButton
EventHandler Sub Action() html.PreferencesIdentifierMBS=prefid.text End EventHandler
End Control
Control PushButton6 Inherits PushButton
ControlInstance PushButton6 Inherits PushButton
EventHandler Sub Action() prefid.text=html.PreferencesIdentifierMBS End EventHandler
End Control
Control textencoding Inherits TextField
ControlInstance textencoding Inherits TextField
End Control
Control StaticText4 Inherits Label
ControlInstance StaticText4 Inherits Label
End Control
Control PushButton7 Inherits PushButton
ControlInstance PushButton7 Inherits PushButton
EventHandler Sub Action() html.CustomTextEncodingNameMBS=textencoding.text End EventHandler
End Control
Control PushButton8 Inherits PushButton
ControlInstance PushButton8 Inherits PushButton
EventHandler Sub Action() TextEncoding.text=html.CustomTextEncodingNameMBS End EventHandler
End Control
Control UserAgent Inherits TextField
ControlInstance UserAgent Inherits TextField
End Control
Control StaticText5 Inherits Label
ControlInstance StaticText5 Inherits Label
End Control
Control PushButton9 Inherits PushButton
ControlInstance PushButton9 Inherits PushButton
EventHandler Sub Action() html.CustomUserAgentMBS=useragent.text End EventHandler
End Control
Control PushButton10 Inherits PushButton
ControlInstance PushButton10 Inherits PushButton
EventHandler Sub Action() UserAgent.text=html.CustomUserAgentMBS End EventHandler
End Control
Control ApplicationName Inherits TextField
ControlInstance ApplicationName Inherits TextField
End Control
Control StaticText6 Inherits Label
ControlInstance StaticText6 Inherits Label
End Control
Control PushButton11 Inherits PushButton
ControlInstance PushButton11 Inherits PushButton
EventHandler Sub Action() html.ApplicationNameForUserAgentMBS=ApplicationName.text End EventHandler
End Control
Control PushButton12 Inherits PushButton
ControlInstance PushButton12 Inherits PushButton
EventHandler Sub Action() ApplicationName.text=html.ApplicationNameForUserAgentMBS End EventHandler
End Control
Control StaticText7 Inherits Label
ControlInstance StaticText7 Inherits Label
End Control
Control StaticText8 Inherits Label
ControlInstance StaticText8 Inherits Label
End Control
Control StaticText9 Inherits Label
ControlInstance StaticText9 Inherits Label
End Control
Control PushButton13 Inherits PushButton
ControlInstance PushButton13 Inherits PushButton
EventHandler Sub Action() html.GoBackMBS End EventHandler
End Control
Control PushButton14 Inherits PushButton
ControlInstance PushButton14 Inherits PushButton
EventHandler Sub Action() html.GoForwardMBS End EventHandler
End Control
Control PushButton15 Inherits PushButton
ControlInstance PushButton15 Inherits PushButton
EventHandler Sub Action() dim s as string // "return 1+2;" in Safari 2 s=html.EvaluateJavaScriptMBS("1+2;") if s="" then MsgBox "Failed." else MsgBox "1+2 is "+s end if s=html.EvaluateJavaScriptMBS("navigator.userAgent") if s="" then MsgBox "Failed." else MsgBox "user agent: "+s end if End EventHandler
End Control
Control PushButton16 Inherits PushButton
ControlInstance PushButton16 Inherits PushButton
EventHandler Sub Action() dim s as string s=html.RenderPDFMBS s=left(s,1000) MsgBox s End EventHandler
End Control
Control PushButton17 Inherits PushButton
ControlInstance PushButton17 Inherits PushButton
EventHandler Sub Action() dim s as string s=html.RenderEPSMBS s=left(s,1000) MsgBox s End EventHandler
End Control
Control SearchFor Inherits TextField
ControlInstance SearchFor Inherits TextField
End Control
Control StaticText10 Inherits Label
ControlInstance StaticText10 Inherits Label
End Control
Control CheckBox1 Inherits CheckBox
ControlInstance CheckBox1 Inherits CheckBox
End Control
Control CheckBox2 Inherits CheckBox
ControlInstance CheckBox2 Inherits CheckBox
End Control
Control CheckBox3 Inherits CheckBox
ControlInstance CheckBox3 Inherits CheckBox
End Control
Control PushButton18 Inherits PushButton
ControlInstance PushButton18 Inherits PushButton
EventHandler Sub Action() if not html.SearchForMBS(SearchFor.text, CheckBox1.Value,CheckBox2.Value,CheckBox3.Value) then beep end if End EventHandler
End Control
Control Separator1 Inherits Separator
ControlInstance Separator1 Inherits Separator
End Control
Control Separator2 Inherits Separator
ControlInstance Separator2 Inherits Separator
End Control
Control PushButton19 Inherits PushButton
ControlInstance PushButton19 Inherits PushButton
EventHandler Sub Action() html.LoadURLMBS EditField1.text End EventHandler
End Control
Control PushButton20 Inherits PushButton
ControlInstance PushButton20 Inherits PushButton
EventHandler Sub Action() // Load and prefer cache const UseProtocolCachePolicy=0 const ReloadIgnoringCacheData=1 const ReturnCacheDataElseLoad=2 const ReturnCacheDataDontLoad=3 html.LoadURLMBS EditField1.text, ReturnCacheDataElseLoad, 5.0 End EventHandler
End Control
Control PushButton21 Inherits PushButton
ControlInstance PushButton21 Inherits PushButton
EventHandler Sub Action() html.LoadHTMLStringMBS "<p>Hello World</p>","" // no base url End EventHandler
End Control
Control StaticText11 Inherits Label
ControlInstance StaticText11 Inherits Label
End Control
Control Slider1 Inherits Slider
ControlInstance Slider1 Inherits Slider
EventHandler Sub ValueChanged() html.TextSizeMultiplierMBS=me.Value/100.0 End EventHandler
End Control
Control PushButton22 Inherits PushButton
ControlInstance PushButton22 Inherits PushButton
EventHandler Sub Action() html.ReloadMBS End EventHandler
End Control
Control PushButton23 Inherits PushButton
ControlInstance PushButton23 Inherits PushButton
EventHandler Sub Action() html.StopLoadingMBS End EventHandler
End Control
Control PushButton24 Inherits PushButton
ControlInstance PushButton24 Inherits PushButton
EventHandler Sub Action() // Load html data as html html.LoadHTMLStringMBS "<p>Hello World</p>","text/html","","" End EventHandler
End Control
Control PushButton25 Inherits PushButton
ControlInstance PushButton25 Inherits PushButton
EventHandler Sub Action() // Load html data as plain text html.LoadHTMLStringMBS "<p>Hello World</p>","text/plain","","" End EventHandler
End Control
Control PushButton26 Inherits PushButton
ControlInstance PushButton26 Inherits PushButton
EventHandler Sub Action() dim n as NSImageMBS n=html.RenderWebsiteImageMBS if n=nil then MsgBox "failed" else dim w as new window2 w.backdrop=n.CopyPictureWithMask end if End EventHandler
End Control
Control PushButton27 Inherits PushButton
ControlInstance PushButton27 Inherits PushButton
EventHandler Sub Action() dim n as NSImageMBS n=html.WebViewMBS.RenderImage if n=nil then MsgBox "failed" else dim w as new window2 w.backdrop=n.CopyPictureWithMask end if End EventHandler
End Control
Control ProgressBar1 Inherits ProgressBar
ControlInstance ProgressBar1 Inherits ProgressBar
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() ProgressBar1.Value=html.EstimatedProgressMBS*100.0 End EventHandler
End Control
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class Window2 Inherits Window
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...