Platforms to show: All Mac Windows Linux Cross-Platform

/Cocoa/HTMLViewer Mac/WebUIDelegate
Feedback.

Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /Cocoa/HTMLViewer Mac/WebUIDelegate
This example is the version from Wed, 2nd Mar 2010.
Notes: Last modified: Wed, 2nd Mar 2010
Class MainWindow
Inherits Window
// Controls
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
Sub Action() Handles Event
// This timer is to make updates happen not too often

ProgressBar1.Value=100*web.EstimatedProgressMBS

End Sub
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
Sub Action() Handles Event
web.Visible=me.Value
End Sub
End ControlInstance
ControlInstance
End ControlInstance

// Properties
Protected Dim wui As myuIEvents

// Event implementations
Sub Close()
if wui<>nil then
wui.w=nil
end if

End Sub
Sub Open()

wui=new MyUIEvents
wui.w=self

web.InstallWebUIDelegateMBS wui

if not me.Composite then
MsgBox "This window must be composite!"
end if


End Sub
End Class

Class App
Inherits Application
// Event implementations
Sub Open()

if TargetMachO then
// ok
else
MsgBox "This project works only as MachO target on Mac OS X."
end if

MainWindow.show
MainWindow.web.LoadHTMLStringMBS HTMLCode.EditField1.text,""



End Sub
End Class

Class MyUIEvents
Inherits WebUIDelegateMBS
// Properties
Dim w As mainwindow

// Event implementations
Function RunJavaScriptTextInputPanelWithPrompt(prompt as String, defaultText as String) As String
system.debuglog "RunJavaScriptTextInputPanelWithMessage"
MsgBox prompt+" "+defaultText
End Function
Function RunJavaScriptConfirmPanelWithMessage(message as String) As boolean
system.debuglog "RunJavaScriptConfirmPanelWithMessage"
MsgBox message

End Function
Sub RunJavaScriptAlertPanelWithMessage(message as String)
system.debuglog "RunJavaScriptAlertPanelWithMessage"
MsgBox message
End Sub
Function SetContentRect(left as double, top as double, width as double, height as double) As boolean
system.debuglog "SetContentRect in Realbasic"
system.debuglog str(left)+"/"+str(top)+" "+str(Width)+" "+str(Height)
End Function
Sub SetResizable(resizeable as boolean)
system.debuglog "SetResizeable in Realbasic"

End Sub
Function SetStatusBarVisible(visible as boolean) As boolean
system.debuglog "SetStatusbarVisible in Realbasic"

End Function
Function SetToolbarsVisible(visible as boolean) As boolean
system.debuglog "SetToolbarsVisible in Realbasic"

End Function
Function IsResizable() As boolean
system.debuglog "IsResizeable in Realbasic"

End Function
Function IsStatusBarVisible() As boolean
system.debuglog "IsResizeable in Realbasic"
Return true
End Function
Function SetFrame(left as double, top as double, width as double, height as double) As boolean
system.debuglog "SetFrame in Realbasic"
system.debuglog str(left)+"/"+str(top)+" "+str(Width)+" "+str(Height)

End Function
Function GetContentRect(byref left as double, byref top as double, byref width as double, byref height as double) As boolean
system.debuglog "GetContentRect in Realbasic"

top=w.web.top
left=w.web.left
Width=w.web.Width
Height=w.web.Height

// Return true

End Function
Function SetStatusText(text as String) As boolean
system.debuglog "SetStatusText in Realbasic"
system.debuglog text

w.StatusText.text=text

End Function
Function GetStatusText() As String
system.debuglog "GetStatusText in Realbasic"
Return w.StatusText.text


End Function
Function GetFrame(byref left as double, byref top as double, byref width as double, byref height as double) As boolean
system.debuglog "GetFrame in Realbasic"

left=w.Left
top=w.top
width=w.Width
height=w.Height

// Return true

End Function
Function AreToolbarsVisible() As boolean
system.debuglog "AreToolbarsVisible in Realbasic"
Return false
End Function
Function WindowClose() As boolean
system.debuglog "Closed in Realbasic"

w.Close

End Function
Function WindowUnfocus() As boolean
system.debuglog "Unfocus in Realbasic"

End Function
Function WindowShow() As boolean
system.debuglog "Show in Realbasic"

w.show

End Function
Function CreateWithRequest(URL as string, CachePolicy as integer, TimeOutInterval as double, mainDocumentURL as string) As object
dim w as MainWindow

system.debuglog "CreateWebViewWithRequest in Realbasic"
system.debuglog url

w=new MainWindow
w.web.LoadURLMBS url,CachePolicy,TimeOutInterval

Return w.web


End Function
Function WindowFocus() As boolean
system.debuglog "Focus in Realbasic"

w.show


End Function
Sub Open()
'MsgBox "Open"
End Sub
Sub Close()
'MsgBox "Close"
End Sub
Function runOpenPanelForFileButtonWithResultListener(listener as WebOpenPanelResultListenerMBS) As boolean
dim o as OpenDialog
dim f as FolderItem

o=new OpenDialog

f=o.ShowModal

if f=nil then
listener.cancel
else
listener.chooseFilename f
end if

Return true

End Function
End Class

Class HTMLCode
Inherits Window
// Controls
ControlInstance
End ControlInstance
End Class


See also:




Links
MBS Realbasic tutorial videos - Pfarrgemeinde Ministranten Nickenich