WebBrowser - Kirix Documentation

Developer Resources

WebBrowser

Overview

The WebBrowser class represents a web browser control.

Base Class

FormControl

Constructor

WebBrowser(x_pos : Integer, y_pos : Integer, width : Integer, height : Integer)

Arguments

x_pos
The x position of the control.
y_pos
The y position of the control.
width
The width of the control.
height
The height of the control.

Events

WebBrowser.navigated
Fired when the web control has been navigated to a new location.

Methods

WebBrowser.canCopyImageContents
Indicates if a the current image contents can be copied.
WebBrowser.canCopyImageLocation
Indicates if a the current image location can be copied.
WebBrowser.canCopyLinkLocation
Indicates if a the current link location can be copied.
WebBrowser.canCopySelection
Indicates if a there's a selection in the web control that can be copied.
WebBrowser.canCutSelection
Indicates if a there's a selection in the web control that can be cut.
WebBrowser.canPaste
Indicates in the current contents of the system clipboard can be pasted.
WebBrowser.copyImageContents
Copies the current image contents to the system clipboard.
WebBrowser.copyImageLocation
Copies the current image location to the system clipboard.
WebBrowser.copyLinkLocation
Copies the current link location to the system clipboard.
WebBrowser.copySelection
Copies the current selection to the system clipboard.
WebBrowser.cutSelection
Cuts the current selection.
WebBrowser.getLocation
Gets the current URI for the web control.
WebBrowser.goBack
Opens the previous URI in the list of navigated URIs.
WebBrowser.goForward
Opens the next URI in the list of navigated URIs.
WebBrowser.navigate
Opens a URI for the web control.
WebBrowser.paste
Pastes the contents of the system clipboard to the web control.
WebBrowser.reload
Reloads the current URI in the web control.
WebBrowser.selectAll
Selects all the selectable content of the web control.
WebBrowser.selectNone
Deselects all the selected content of the web control.
WebBrowser.showHypertext
Displays hypertext in a the browser control
WebBrowser.stop
Stops the web control from loading a URI that's currently being loaded.
WebBrowser.waitUntilReady
Waits for the web control's current load cycle to finish

Inherited Methods

FormControl.captureMouse
Captures the mouse on this form control.
FormControl.disablePaint
Disables the window from redrawing itself.
FormControl.enablePaint
Enables the window to redraw itself.
FormControl.getBackgroundColor
Gets the background color of the form control.
FormControl.getClientSize
Gets the client size of the form control.
FormControl.getEnabled
Indicates whether or not a form control is enabled.
FormControl.getFont
Gets the default font for the text of form control.
FormControl.getForegroundColor
Gets the foreground color of the form control.
FormControl.getMaxSize
Gets the maximum size of the form control.
FormControl.getMinSize
Gets the minimum size of the form control.
FormControl.getMousePosition
Gets the mouse position relative to this form control.
FormControl.getNativeHandle
Gets the native handle of the window/control
FormControl.getPosition
Gets the position of a form control.
FormControl.getSize
Gets the size of the form control.
FormControl.invalidate
Invalidates a form control, which will cause it to be repainted on the next paint event.
FormControl.refresh
Refreshes a form control, which immediately repaints the entire form control.
FormControl.releaseMouse
Releases the mouse from being captured on this form control.
FormControl.setBackgroundColor
Sets the background color of the form control.
FormControl.setClientSize
Sets the client size of a form control.
FormControl.setEnabled
Enables or disables the form control.
FormControl.setFocus
Sets the focus to the form control.
FormControl.setFont
Sets the default font for the text of the form control.
FormControl.setForegroundColor
Sets the foreground color of the form control.
FormControl.setMaxSize
Sets the maximum size of a form control.
FormControl.setMinSize
Sets the minimum size of a form control.
FormControl.setPosition
Sets the position of a form control relative to the the form control's parent.
FormControl.setSize
Sets the size of a form control.
FormControl.show
Shows or hides the form control.
FormControl.update
Updates a form control, which will immediately repaint any invalid areas.

Example

// create our own class derived from form
class MyForm extends Form
{
    var m_url_textbox;
    var m_browser;

    function MyForm()
    {
        super("Mini Browser", 100, 100, 800, 600);

        m_url_textbox = new TextBox("https://www.google.com", 0, 0, 500);
        m_url_textbox.enterPressed.connect(this, onUrlEnterPressed);

        m_browser = new WebBrowser(0, 50, 500, 350);
        m_browser.navigate("https://www.google.com");

        // vertical sizer
        var main_layout = new BoxLayout(Layout.Vertical);
        main_layout.add(m_url_textbox, 0, Layout.Expand | Layout.All, 5);
        main_layout.add(m_browser, 1, Layout.Expand);
        setLayout(main_layout);
    }

    function onUrlEnterPressed()
    {
        // user pressed enter, navigate to the new location
        m_browser.navigate(m_url_textbox.getText());
    }
}

// create an instance of our derived MyForm class
// and show it
var f = new MyForm;
f.show();
f = null;

// start the event loop; the application will exit as
// soon as the button is clicked
Application.run();

WebBrowser.canCopyImageContents

function WebBrowser.canCopyImageContents() : Boolean

Returns

Returns true if the current image contents can be copied, and false otherwise.

Description

Returns true if the current image contents can be copied, and false otherwise.

WebBrowser.canCopyImageLocation

function WebBrowser.canCopyImageLocation() : Boolean

Returns

Returns true if the current image location can be copied, and false otherwise.

Description

Returns true if the current image location can be copied, and false otherwise.

WebBrowser.canCopyLinkLocation

function WebBrowser.canCopyLinkLocation() : Boolean

Returns

Returns true if the current link location can be copied, and false otherwise.

Description

Returns true if the current link location can be copied, and false otherwise.

WebBrowser.canCopySelection

function WebBrowser.canCopySelection() : Boolean

Returns

Returns true if there's a selection in the web control that can be copied, and false otherwise.

Description

Returns true if there's a selection in the web control that can be copied, and false otherwise.

WebBrowser.canCutSelection

function WebBrowser.canCutSelection() : Boolean

Returns

Returns true if there's a selection in the web control that can be cut, and false otherwise.

Description

Returns true if there's a selection in the web control that can be cut, and false otherwise.

WebBrowser.canPaste

function WebBrowser.canPaste() : Boolean

Description

Returns true if the current contents of the system clipboard can be pasted, and false otherwise.

WebBrowser.copyImageContents

function WebBrowser.copyImageContents()

Description

Copies the current image contents to the system clipboard.

WebBrowser.copyImageLocation

function WebBrowser.copyImageLocation()

Description

Copies the current image location to the system clipboard.

WebBrowser.copyLinkLocation

function WebBrowser.copyLinkLocation()

Description

Copies the current link location to the system clipboard.

WebBrowser.copySelection

function WebBrowser.copySelection()

Description

Copies the current selection to the system clipboard.

WebBrowser.cutSelection

function WebBrowser.cutSelection()

Description

Cuts the current selection.

WebBrowser.getLocation

function WebBrowser.getLocation() : String

Returns

Returns the current URI for the web control.

Description

Returns the current URI for the web control.

WebBrowser.goBack

function WebBrowser.goBack()

Description

Opens the previous URI in the list of navigated URIs.

WebBrowser.goForward

function WebBrowser.goForward()

Description

Opens the next URI in the list of navigated URIs.

WebBrowser.navigate

function WebBrowser.navigate(location : String)

Arguments

location
The location to open in the web control.

Description

Opens the location in the web control.

WebBrowser.paste

function WebBrowser.paste()

Description

Pastes the contents of the system clipboard to the web control.

WebBrowser.reload

function WebBrowser.reload()

Description

Reloads the current URI in the web control.

WebBrowser.selectAll

function WebBrowser.selectAll()

Description

Selects all the selectable content of the web control.

WebBrowser.selectNone

function WebBrowser.selectNone()

Description

Deselects all the selected content of the web control.

WebBrowser.showHypertext

function WebBrowser.showHypertext(html_text : String) : Boolean

Arguments

html_text
The HTML text that the control should display

Returns

true if the operation succeeded, false otherwise

Description

Display's the text passed in the html_text parameter in the browser control. The text is stored in a temporary file which is removed after the control has been destroyed.

WebBrowser.stop

function WebBrowser.stop()

Description

Stops the web control from loading a URI that's currently being loaded.

WebBrowser.waitUntilReady

function WebBrowser.waitUntilReady(max_milliseconds : Number)

Arguments

max_milliseconds
(optional) The number of milliseconds to wait before returning

Description

Calling this method will cause execution to wait until the web browser has finished loading the web document. It is normally invoked after a call to navigate() is issued. The function may return before all images are loaded, but ensures that the web pages DOM document is fully present. The optional parameter, max_milliseconds, specifies the maximum amount of time the call should wait before returning. If no parameter is specified, the method will wait indefinitely.