BrowserWidget
class in package klyn.gui.windows.browser

    public class BrowserWidget extends Canvas:

Widget
└ Canvas
└ BrowserWidget

Embedded HTML/CSS/JS document viewer implemented by the Klyn GUI stack.

`BrowserWidget` provides local and remote navigation, history, link activation, scrolling, page zoom, images and a deterministic DOM scripting profile without adding a third-party browser dependency. Its retained display list keeps scrolling and repainting independent from HTML parsing and CSS layout. Documents without an explicit CSS font use the same default font and size as the active menu-bar theme.

Example

    import klyn.gui.windows.browser

    browser = BrowserWidget("file:///opt/klyn/docs/api/index.html")
    browser.navigationFailed += lambda(event: BrowserNavigationErrorEvent): print(event.message)

Properties

Modifier and Type | Member | Description
--- | --- | ---
public property | allowScripts `allowScripts as Boolean:` | Whether inline and external scripts may use the embedded DOM profile.
public readonly property | canGoBack `canGoBack as Boolean:` | Whether `goBack()` can select an older history entry.
public readonly property | canGoForward `canGoForward as Boolean:` | Whether `goForward()` can select a newer history entry.
public readonly property | documentTitle `documentTitle as String:` | Current document title.
public readonly property | history `history as BrowserHistory:` | Navigation history retained by this browser.
public property | homeUrl `homeUrl as String:` | URL opened by `goHome()`.
public readonly property | isLoading `isLoading as Boolean:` | Whether a page is currently loading in the background.
public readonly property | scrollX `scrollX as Int:` | Horizontal document scroll position in CSS pixels.
public readonly property | scrollY `scrollY as Int:` | Vertical document scroll position in CSS pixels.
public readonly property | statusText `statusText as String:` | Current status text, usually the link under the pointer.
public property | userStyleSheet `userStyleSheet as String:` | CSS rules supplied by the host application for the displayed document.
public property | zoomFactor `zoomFactor as Double:` | Page-specific zoom factor, clamped to `0.25 .. 5.0`.

Inherited Properties
property Inherited Properties from Widget: accentColor, backgroundColor, borderColor, bottom, canFocus, cornerRadius, cursor, font, foregroundColor, hasFocus, height, isEnabled, isHovered, isManaged, isTabStop, isVisible, layoutParams, margin, maxHeight, maxWidth, minHeight, minWidth, parent, preferredHeight, preferredWidth, resolvedStyleCache, resolvedStyleCacheAppearanceMode, resolvedStyleCacheFont, resolvedStyleCacheRevision, resolvedStyleCacheStateKey, resolvedStyleCacheStyleClass, resolvedStyleCacheZoomRevision, right, size, sizePolicy, styleClass, toolTip, width, window, x, y
Signals

Modifier and Type | Member | Description
--- | --- | ---
public signal property | url `url as String:` | Current effective document URL.

Events

Modifier and Type | Member | Description
--- | --- | ---
public event | documentCompleted `documentCompleted as BrowserNavigationEvent` | Emitted after styles, scripts and layout are ready for painting.
public event | navigated `navigated as BrowserNavigationEvent` | Emitted after the main page and blocking resources have loaded.
public event | navigating `navigating as BrowserNavigationEvent` | Emitted immediately before a navigation starts.
public event | navigationFailed `navigationFailed as BrowserNavigationErrorEvent` | Emitted when the requested document cannot be loaded.

Inherited Events
event Inherited Events from Widget: keyPressed, keyReleased, mouseMoved, mousePressed, mouseReleased, mouseWheel, paintRequested, resized
Constructors

Modifier and Type | Member | Description
--- | --- | ---
public | BrowserWidget `BrowserWidget(url as String = "about:blank"):` | Creates an embedded browser and optionally starts navigation.

Methods

Modifier and Type | Member | Description
--- | --- | ---
public | executeScript `executeScript(script as String) as String:` | Executes the embedded DOM scripting profile against the current page.
public | goBack `goBack() as Boolean:` | Navigates to the previous history entry.
public | goForward `goForward() as Boolean:` | Navigates to the following history entry.
public | goHome `goHome() as Void:` | Navigates to `homeUrl`.
public | navigate `navigate(url as String) as Void:` | Starts asynchronous navigation to an absolute URL, relative URL or path.
public | navigateToString `navigateToString(html as String, baseUrl as String = "about:blank", appendHistory as Boolean = true) as Void:` | Loads an in-memory HTML document without filesystem or network access.
public override | paint `paint(painter as Painter) as Void:` | Paints the retained browser display list.
public | refresh `refresh() as Void:` | Reloads the current URL without adding a history entry.
public | scrollBy `scrollBy(deltaX as Int, deltaY as Int) as Void:` | Scrolls relative to the current CSS-pixel position.
public | scrollTo `scrollTo(x as Int, y as Int) as Void:` | Scrolls the document to CSS-pixel coordinates.
public | stop `stop() as Void:` | Cancels the active network or file navigation.

Inherited Methods
method Inherited Methods from Widget: blur, containsPoint, emitKeyPressed, emitKeyReleased, emitMouseMoved, emitMousePressed, emitMouseReleased, emitMouseWheel, handleTabKey, notifyPaintRequested, paint, paintClipped, paintOverlay, repaint, requestFocus, resolvePreferredHeight, resolvePreferredWidth, resolvedFont, setBounds