1. Thomas Chust
  2. racket-webkit

Wiki

Clone wiki

racket-webkit / WebPanel

web-panel%

A web-panel% is a kind of panel% that displays a web page. It implements the control<%> interface but passes web-event% instances to its command method.

Constructor

(new web-panel%
     [callback (or/c (-> (is-a?/c web-panel%) (is-a?/c web-event%) any) #f)]
     [logger logger?]
     [horiz-scrollbar-policy (symbols 'automatic 'always 'never)]
     [vert-scrollbar-policy (symbols 'automatic 'always 'never)]
     ...)


ArgumentDefault Expression
callback#f
logger(make-logger 'web-panel (current-logger))
horiz-scrollbar-policy'automatic
vert-scrollbar-policy'automatic

The callback argument is used to pass web-event% instances to client code. The logger is used to dispatch console messages generated by scripts on the web page.

horiz-scrollbar-policy and vert-scrollbar-policy determine which scrollbars should be shown around the web page.

Methods

scrollbar-policy (final)

(send web-panel scrollbar-policy) -> (values
                                       (symbols 'automatic 'always 'never)
                                       (symbols 'automatic 'always 'never))

Retrieve the current setting of the scrollbar policy.

(send web-panel scrollbar-policy
      [horiz-scrollbar-policy (symbols 'automatic 'always 'never)]
      [vert-scrollbar-policy (symbols 'automatic 'always 'never)]) -> void?

Changes the current scrollbar policy.

command (specified by control<%>)

(send web-panel command [event (is-a?/c web-event%)]) -> any

Invokes the callback, if any, on the web-panel and the given event.

on-size (specified by window<%>, augmentable)

(send web-panel on-size
      [width exact-nonnegative-integer?]
      [height exact-nonnegative-integer?]) -> void?

Ensures that the embedded native WebKitWebView is correctly resized, then invokes the augment.

get-load-status (final)

(send web-panel get-load-status) -> (symbols 'provisional
      				    	     'committed
					     'finished
					     'first-visually-non-empty-layout
					     'failed)

Retrieves the current load status of the page.

get-progress (final)

(send web-panel get-progress) -> real?

Retrieves the current degree of loading and rendering progress.

on-new-dom-window

(send web-panel on-new-dom-window [js-window jsproxy?]) -> void?

This method is invoked whenever a new DOM window object is created for a web page. Override this method to perform any custom setup for interation between Racket and JavaScript.

The default implementation adds a single method called command to the window object. When this method is invoked from JavaScript, it marshals its single argument to Racket, wraps it into a web-event% with status set to 'script-command and calls the command method on the event.

on-new-plugin-subwindow

(send web-panel on-new-plugin-subwindow
      [mime-type string?]
      [uri (or/c string? #f)]
      [params (hash/c symbol? string?)]) -> (or/c (is-a?/c subwindow<%>) #f)

This method is invoked when a widget has to be created for an HTML <object> or <embed> element. Override this method to create and return a subwindow<%> with the web-panel as its parent in order to embed Racket GUI elements into a web page. Return #f if no widget should be created for an embedding element.

The default implementation constantly returns #f.

get-uri (final)

(send web-panel get-uri) -> (or/c string? #f)

Retrieves the URI of the current web page.

get-encoding (final)

(send web-panel get-encoding) -> string?

Retrieves the name of the current web page's character encoding.

get-plain-label (specified by window<%>, final)

(send web-panel get-plain-label) -> (or/c string? #f)

Retrieves the title of the current web page.

get-label (specified by window<%>, final)

(send web-panel get-plain-label) -> (or/c label-string? #f)

Retrieves the title of the current web page, escaped as a label.

set-label (specified by window<%>, final)

(send web-panel set-label [label any]) -> void?

Always raises an exception because the web page title is immutable from the outside.

on-label-change

(send web-panel on-label-change [label (or/c label-string? #f)]) -> any

This method is invoked when the title of the web page changes.

The default implementation wraps the new label into a web-event% with status set to 'title-changed and calls the command method on the event.

on-status-message

(send web-panel on-status-message [message string?]) -> any

This method is invoked when the title of the web page changes.

The default implementation wraps the new message into a web-event% with status set to 'status-message and calls the command method on the event.

on-console-message

(send web-panel on-console-message
      [message string?]
      [line integer?] [source (or/c string? #f)]) -> any/c

This method is invoked when a script in the web page emits a console message. If the return value is true, it indicates that event propagation should stop.

The default implementation calls (log-message logger 'info message (cons line source)) and returns #t.

load

(send web-panel load
      #:uri [uri string?]
      #:content [content (or/c bytes? #f)]
      #:mime-type [mime-type string?]
      #:encoding [encoding string?]) -> void?


ArgumentDefault Expression
uri"about:blank"
content#f
mime-type"text/html"
encoding"UTF-8"

Instructs the web-panel to load a new page.

If a byte string is passed as the content argument, the data to load is taken from its contents. The mime-type and encoding arguments determine how the content is interpreted in this case, the uri argument indicates the base URI of the content.

If content is #f, only the uri argument is relevant and specifies the location where data should be loaded from.

reload

(send web-panel reload [bypass-cache? any/c]) -> void?

Instructs the web-panel to reload the current page, possibly bypassing any caches.

stop-loading

(send web-panel stop-loading) -> void?

Instructs the web-panel to abort any current loading operation.

go-back

(send web-panel go-back [steps integer?]) -> boolean?

Instructs the web-panel to load a page some steps back in the navigation history. Returns whether the operation could be performed.

go-forward

(send web-panel go-forward [steps integer?]) -> boolean?

Instructs the web-panel to load a page some steps forward in the navigation history. Returns whether the operation could be performed.

Updated