BBjHtmlView

Description

The BBjHtmlView control displays HTML files, and can act as a complete embedded web browser, with support for HTML5, CSS, and JavaScript.

The BBjHtmlView can be configured through STBL options to be either an embedded WebKit browser using JavaFX, or an embedded Chromium-based browser. See STBL Options for BBjHtmlView below.

Access to the JAVAFX_HTMLVIEW and CHROMIUM_HTMLVIEW features requires an active Software Asset Management (SAM) subscription. See Benefits of ‘Software Asset Management' Feature Line.

Implemented Interfaces

DragSource, DropTarget, Focusable, TabTraversable

Creation

BBjAPI > BBjSysGui > BBjWindow > BBjHtmlView

A BBjHtmlView object is created through the following BBjWindow methods:

Return Value Method

BBjHtmlView

addHtmlView(int  ID, number x, number y, number w, number h, string html)

BBjHtmlView

addHtmlView(int ID, number x, number y, number w, number h, string html, string flags)

BBjHtmlView

addHtmlView(int ID, number x, number y, number w, number h, string html, string flags, string chromium_switches$)

BBjHtmlView

addHtmlView(int ID, String html)

BBjHtmlView

addHtmlView(int ID, String html, string flags)

BBjHtmlView

addHtmlView(int ID, String html, string flags, string chromium_switches)

BBjHtmlView

addHtmlView(String html)

BBjHtmlView

addHtmlView(String html, string flags)

BBjHtmlView

addHtmlView(String html, string flags, string chromium_switches)

Methods of BBjHtmlView

Return Value Method

int

executeAsyncScript(string script)

Object

executeScript(string script)

boolean

getAutoNavigate()

string

getClientType()

string

getClientVersion()

string getDownloadDirectory()

BBjImage

getImage()

string

getText()

string

getUrl()

string

getUserAgent()

void

injectScript(string script)

void

injectScript(string script, boolean top)

void

injectUrl(string url)

void

injectUrl(string url, boolean top)

boolean

print()

void

setAutoNavigate(boolean autoNavigate)

void setDownloadDirectory(string directory)

void

setUrl(string url)

void

setUrl(string url, boolean reload)

void

setUserAgent(string userAgent)

Closed Methods of BBjHtmlView implemented for DragSource

Return Value Method

int

getDragActions()

string

getDragType()

void

setDragActions(int actions)

void

setDragType(string type)

Closed Methods of BBjHtmlView implemented for DropTarget

Return Value

Method

int

getDropActions()

void

setDropActions(int actions)

BBjVector

getDropTypes()

void

setDropTypes(BBjVector types)

Closed Methods of BBjHtmlView implemented for Focusable

Return Value

Method

boolean

isFocusable()

void

setFocusable(boolean p_focus)

Closed Methods of BBjHtmlView implemented for TabTraversable

Return Value

Method

boolean

isTabTraversable()

void

setTabTraversable(boolean trav)

Methods of BBjHtmlView inherited from BBjControl

Constants inherited from BBjControl

Closed Events

Callback Code

Object-oriented Event

Read Record Event

Code

ON_DROP_TARGET_DROP

BBjDropTargetDropEvent

Drop Target Drop Event

D

ON_GAINED_FOCUS

BBjGainedFocusEvent

Control Focus Gained/Lost Event

f

ON_EXECUTE_SCRIPT

BBjExecuteScriptEvent

ExecuteScriptEvent

x

ON_HTMLVIEW_DOWNLOAD

BBjHtmlViewDownloadEvent HtmlView Download Event x

ON_HYPERLINK_ACTIVATE

BBjHyperlinkActivateEvent

Hyperlink Activate Event

x

ON_HYPERLINK_ENTER

BBjHyperlinkEnterEvent

Hyperlink Enter Event

x

ON_HYPERLINK_EXIT

BBjHyperlinkExitEvent

Hyperlink Exit Event

x

ON_LOST_FOCUS

BBjLostFocusEvent

Control Focus Gained/Lost Event

f

ON_MOUSE_ENTER

BBjMouseEnterEvent

Mouse Enter/Exit Event

E

ON_MOUSE_EXIT

BBjMouseExitEvent

Mouse Enter/Exit Event

E

ON_NATIVE_JAVASCRIPT

BBjNativeJavaScriptEvent

Native JavaScript Event

x

ON_PAGE_LOADED

BBjPageLoadedEvent

Page Loaded Event

x

ON_POPUP_REQUEST

BBjPopupRequestEvent

Popup Request Event

r

ON_RIGHT_MOUSE_DOWN

BBjRightMouseDownEvent

Right Mouse Button Down Event

R

ON_SCRIPT_FAILED

BBjScriptFailedEvent

Script Failed Event

x

ON_SCRIPT_LOADED

BBjScriptLoadedEvent

Script Loaded Event

x

Closed BUI CSS

The visual appearance of BUI controls is defined using CSS (cascading style sheets) rules. Easily change the default colors, border, and other settings by customizing these rules, all without changing any application code. See CSS API for a high-level overview of BUI CSS.

The BBjHtmlView control is a <div> containing a content field with a class name of .BBjHtmlView-content. If the content is set using setUrl(), it is an <iframe>. If the content is set using setText(), it is a <div> containing the specified HTML. The BBjHtmlView defines the following CSS style names:

.BBjHtmlView (the top level control)

.BBjHtmlView-content (the content, either an iframe or a div)

.BBjHtmlView.bbj-disabled (the control is disabled)

Closed STBL Options for BBjHtmlView

The BBjHtmlView can be configured through STBL options to be either an embedded WebKit browser using JavaFX, or an embedded Chromium-based browser. Using the Chromium browser engine is limited to the operating systems and platforms on which the Chromium engine is supported.

To change the type of browser used by the BBjHtmlView, use the STBL("!OPTIONS") JAVAFX_HTMLVIEW option and the STBL("!OPTIONS") CHROMIUM_HTMLVIEW option.

Access to the JAVAFX_HTMLVIEW and CHROMIUM_HTMLVIEW features requires an active Software Asset Management (SAM) subscription. See Benefits of ‘Software Asset Management' Feature Line.

If the Chromium-based BBjHtmlView is used, the STBL("!CHROMIUM_SWITCHES") string can specify an arbitrary number of space-delimited Chromium command-line switches (e.g. "--remote-debugging-port=9223 --lang=de"). These switches are passed on to CHROMIUM_HTMLVIEW BBjHtmlView clients, unless the version of the addHtmlView method that explicitly specifies the chromium_switches$ parameter is used.

Closed Version History

BBj 19.10: Added the STBL("!CHROMIUM_SWITCHES") option.

BBj 19.0: Added the STBL("!OPTIONS") CHROMIUM_HTMLVIEW option.

BBj 15.0: Added the STBL("!OPTIONS") JAVAFX_HTMLVIEW option.

BBj 7.0: BBjHtmlView first introduced.

Example

rem ' BBjHtmlView
url$ = "http://www.useragentstring.com/"
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
if info(3,6)<>"5" and info(3,6)<>"6" then
   client = msgbox("BBjHtmlView Client",7+32+512,"BBjHtmlView","Swing","JavaFX","Chromium")
   switch client
      case 1; rem ' Swing
         print stbl("!OPTIONS","CHROMIUM_HTMLVIEW=FALSE",ERR=*NEXT)
         print stbl("!OPTIONS","JAVAFX_HTMLVIEW=FALSE",ERR=*NEXT)
         break
      case 2; rem ' JavaFX
         print stbl("!OPTIONS","CHROMIUM_HTMLVIEW=FALSE",ERR=*NEXT)
         print stbl("!OPTIONS","JAVAFX_HTMLVIEW=TRUE",ERR=*NEXT)
         break
      case 3; rem ' Chromium
         print stbl("!OPTIONS","CHROMIUM_HTMLVIEW=TRUE",ERR=*NEXT)
         print stbl("!OPTIONS","JAVAFX_HTMLVIEW=TRUE",ERR=*NEXT)
         break
   swend
endif
window! = sysgui!.addWindow(25,25,600,500,url$,$00090083$)
window!.setCallback(window!.ON_CLOSE,"eoj")
window!.setCallback(window!.ON_RESIZE,"resize")
htmlview! = window!.addHtmlView(102,25,25,550,450,"",$$)
htmlview!.setUrl(url$)
clientType$ = htmlview!.getClientType()
clientVersion$ = htmlview!.getClientVersion()
title$ = window!.getTitle() + " " + clientType$ + " " + clientVersion$
window!.setTitle(title$)
process_events

eoj:
release

resize:
  gosub event
  width = event!.getWidth() - 50
  height = event!.getHeight() - 50
  htmlview!.setSize(width,height)
  print width,height
return

event:
  event! = sysgui!.getLastEvent()
  print event!.getEventName()," ",event!.getControl()
return

See Also

BBjAPI

BBjSysGui

BBjWindow

CALLBACK Verb - Register BBj Subroutine

STBL("!OPTIONS") JAVAFX_HTMLVIEW

STBL("!OPTIONS") CHROMIUM_HTMLVIEW

Focusable

TabTraversable

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.