Player APIs (BrightScript & Ja...
...
Object Reference
Presentation and Widget Object...

roHtmlWidgetEvent

4min
if an romessageport is attached to an rohtmlwidget , it will receive rohtmlwidgetevent objects when something happens to the parent rohtmlwidget instance ifuserdata setuserdata(user data as object) sets the user data that will be returned when events are raised getuserdata() as object returns the user data that has previously been set via setuserdata() it will return invalid if no data has been set ifhtmlwidgetevent getdata() as roassociativearray returns the event data as an associative array with the following key/value pairs reason string string the cause of the event, which can be one of the following "load started" the html widget has started loading a page "load finished" the html widget completed loading a page "load error" the html widget failed to load a page use the uri key to identify the failing resource and the message key to retrieve some explanatory text "download request" the html widget instance has received a download request the chromium instance does not process download requests for mime types it doesn't recognize (e g pdfs); instead, it passes this event, along with the mime type and url parameters to the brightscript autorun for processing "new window request" the html widget instance has received a request to open a uri in a new window this request will normally come from html anchors with "target= blank" / "target= top" or the javascript window\ open() method the requested uri is specified in the uri parameter javascript dialog string string if the html widget instance has received a javascript alert, confirmation, etc , brightscript will respond by calling the rohtmlwidget acceptdialog(responseasstring) and rejectdialog() methods see rohtmlwidget docid\ xljq5 yhdma2ssmpzimtk if no response is provided within one second, rohtmlwidget auto rejects the dialog attempt, and if these apis are called when there is no dialog request on rohtmlwidget, they have no effect this parameter was added in bos 8 5 16 message string string the message that the javascript dialog will display (applicable for reason "javascript dialog" only), or explanatory text related to the load failure (applicable for reason "load error" only) this property exists for multiple event types, but it has different meanings for different event types default text string string if a javascript prompt dialog asks the user to enter text, this default text will be displayed in the input field this field will be empty for other dialog types (applicable for reason "javascript dialog" only) this parameter was added in bos 8 5 16 type int int the dialog type for the “javascript dialog” event either 0 for alert, 1 for confirm, 2 for prompt, 3 for an "onbeforeunload event" (applicable for reason "javascript dialog" only) this parameter was added in bos 8 5 16 security origin string string the security origin of the request (applicable for reason "javascript dialog" only) this parameter was added in bos 8 5 16 uri string string the uri of the failing resource or new window request (applicable for reason "load error" or reason "new window request" ) mime type string string the mime type of the download request (applicable for reason "download request" only) url string string the url of the download request (applicable for reason "download request" only) example the following event loop waits for an html widget event if the event indicates that a pdf download request has been received, the script passes the relevant data to a createpdfrenderer() function that is not defined here while true 	ev = wait(0, gaa mp) 	print "=== bs received event ";type(ev) 	if type(ev) = "rohtmlwidgetevent" then 	 eventdata = ev getdata() 	 if type(eventdata) = "roassociativearray" and type(eventdata reason) = "rostring" then 	 if eventdata reason = "load error" then 	 print "=== bs html load error "; eventdata message 	 else if eventdata reason = "load finished" then 	 print "=== bs received load finished" 	 receivedloadfinished = true 	 else if eventdata reason = "message" then 	 ' to use this msgport postbsmessage({text "my message"}); 	 else if eventdata reason = "load started" then 	 print "=== bs received load started" 	 else if eventdata reason = "download request" then 	 print "=== bs received a download request" 	 if eventdata mime type = "application/pdf" then 	 createpdfrenderer("file ///index html?file=" + eventdata url) 	 endif 	 else 	 print "======= unhandled html event =========" 	 print eventdata reason 	 endif 	 else 	 print "=== bs unknown eventdata "; type(eventdata) 	 endif 	endif endwhile