Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacControls/HTMLViewer Mac/DOM Form Fields
Function:
Required plugins for this example: MBS MacBase Plugin, MBS MacCocoa Plugin, MBS MacControls Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacControls/HTMLViewer Mac/DOM Form Fields
This example is the version from Sun, 17th Mar 2012.
Project "DOM Form Fields.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control HTMLViewer1 Inherits HTMLViewer
ControlInstance HTMLViewer1 Inherits HTMLViewer
EventHandler Sub Open() me.LoadURL "http://www.google.com" End EventHandler
End Control
Control EditField1 Inherits TextField
ControlInstance EditField1 Inherits TextField
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() dim di as DOMHTMLInputElementMBS di=FindField("f","q") if di=nil then MsgBox "Failed to find input field on the google form." else EditField1.text=di.value end if End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() dim di as DOMHTMLInputElementMBS di=FindField("f","q") if di=nil then MsgBox "Failed to find input field on the google form." else di.value=EditField1.text end if End EventHandler
End Control
EventHandler Sub Open() if not TargetMachO then MsgBox "This example works only on MachO targets!" Return end if End EventHandler
Function FindField(d as domnodeMBS, fieldname as string) As domhtmlinputElementMBS dim n as DOMNodeMBS dim i as DOMHTMLInputElementMBS if d=nil then Return nil n=d.firstChild while n<>nil if n isa DOMHTMLInputElementMBS then i=DOMHTMLInputElementMBS(n) if i.name=fieldname then Return i end if i=FindField(n, fieldname) if i<>Nil then return i n=n.nextSibling wend End Function
Function FindField(formname as string, fieldname as string) As domhtmlinputElementMBS dim d as DOMDocumentMBS dim hd as DOMHTMLDocumentMBS dim hc as DOMHTMLCollectionMBS dim dn as DOMNodeMBS d=HTMLViewer1.mainFrameMBS.DOMDocument if d isa DOMHTMLDocumentMBS then hd=DOMHTMLDocumentMBS(d) hc=hd.forms if hc<>Nil then dn=hc.namedItem(formname) if dn<>nil then Return FindField(dn,fieldname) end if end if end if End Function
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
End Project

See also:

Feedback, Comments & Corrections

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





Links
MBS FileMaker Plugins