3 var <onLoadFinished, <onLoadFailed, <onLinkActivated, <onReload, <onJavaScriptMsg;
5 *qtClass { ^'QtCollider::WebView'; }
8 _QWebView_ClearMemoryCaches
12 url { ^this.getProperty( \url ); }
14 url_ { arg address; this.setProperty( \url, address ); }
16 title { ^this.getProperty( \title ); }
18 // Get the displayed content in html form.
19 html { ^this.getProperty( \html ); }
22 html_ { arg htmlString;
23 this.invokeMethod( \setHtml, htmlString );
26 selectedText { ^this.getProperty( \selectedText ); }
28 // Try to extract plain text from html content and return it.
29 plainText { ^this.getProperty( \plainText ); }
31 reload { this.invokeMethod( 'reload' ); }
33 back { this.invokeMethod( 'back' ); }
35 forward { this.invokeMethod( 'forward' ); }
37 findText { arg string, reverse = false;
38 this.invokeMethod( \findText, [string, reverse] );
41 evaluateJavaScript { arg script;
42 this.invokeMethod( \evaluateJavaScript, script );
45 // The given function will be evaluated when a page has loaded successfully.
46 // The calling QWebView object is passed to the function.
48 onLoadFinished_ { arg func;
50 { (func ? onLoadFailed).notNil && (onLoadFinished ? onLoadFailed).isNil }
51 { this.connectMethod( 'loadFinished(bool)', 'prLoadFinished' ); }
52 { (func ? onLoadFailed).isNil && (onLoadFinished ? onLoadFailed).notNil }
53 { this.disconnectMethod( 'loadFinished(bool)', 'prLoadFinished' ); };
55 onLoadFinished = func;
58 // The given function will be evaluated when a page has failed to load.
59 // The calling QWebView object is passed to the function.
61 onLoadFailed_ { arg func;
63 { (func ? onLoadFinished).notNil && (onLoadFinished ? onLoadFailed).isNil }
64 { this.connectMethod( 'loadFinished(bool)', 'prLoadFinished' ); }
65 { (func ? onLoadFinished).isNil && (onLoadFinished ? onLoadFailed).notNil }
66 { this.disconnectMethod( 'loadFinished(bool)', 'prLoadFinished' ); };
71 // After this method is called with a function as an argument, QWebView will not
72 // handle links in any way. Instead, the given function will be evaluated whenever
73 // the user activates (clicks) a link.
75 // The argument passed to the function is the calling QWebView object.
77 // If this method is called with nil argument, QWebView link handling will be
80 onLinkActivated_ { arg func;
81 this.manageFunctionConnection( onLinkActivated, func, 'linkActivated(QString)' );
83 { this.setProperty( \linkDelegationPolicy, 2 ); }
84 { this.setProperty( \linkDelegationPolicy, 0 ); };
85 onLinkActivated = func;
88 // After this method is called with an object as an argument, QWebView will do
89 // nothing when page reload is requested. Instead, the given object's 'value' method
90 // will be called on such event.
92 // The arguments passed to the 'value' method are this QWebView instance and
93 // a String for the requested URL to be reloaded.
95 // If this method is called with nil argument, QWebView's page reload handling will
99 this.manageFunctionConnection( onReload, func, 'reloadTriggered(QString)' );
100 this.setProperty( \delegateReload, func.notNil );
104 onJavaScriptMsg_ { arg func;
105 this.manageFunctionConnection( onJavaScriptMsg, func,
106 'jsConsoleMsg(const QString&, int, const QString&)' );
107 onJavaScriptMsg = func;
110 enterInterpretsSelection { ^this.getProperty( \enterInterpretsSelection ); }
112 enterInterpretsSelection_ { arg bool;
113 this.setProperty( \enterInterpretsSelection, bool );
116 // Set a specific font family to be used in place of a CSS-specified generic font family.
117 // The 'generic' argument must be one of the following symbols:
118 // \standard, \fixed, \serif, \sansSerif, \cursive, \fantasy
120 setFontFamily { arg generic, specific;
121 this.invokeMethod( \setFontFamily, [QWebFontFamily(generic), specific] )
124 //---------------------------------- private --------------------------------------//
126 prLoadFinished { arg ok;
127 if(ok) { onLoadFinished.value(this) } { onLoadFailed.value(this) };
133 - history // returning a string list of urls.