## CwWebView
CwWebView
Description
CwWebView is the common widget that bi-directionally control web page views in VAST applications using Microsoft Edge® and Smalltalk.
Responsibility
CwWebView depends on the platform-specific widget, OSWebViewEdge, and
an image-wide WebView environment <CwWebViewEnvironmentOption>.
The WebView environment is automatically set to a useful state on image startup. No further actions are required unless the user's web view application requires a customized state.
CwWebView receives callbacks from OSWebViewEdge when certain events happen. Data included in the callback structure helps inform what actions can be taken in response to the events. The user can register interest in any of the callbacks:
• xmNnewWindowRequestedCallback
• xmNwindowCloseRequestedCallback
• xmNnavigationCompletedCallback
• xmNnavigationStartingCallback
• xmNdomContentLoadedCallback
• xmNsourceChangedCallback
• xmNdocumentTitleChangedCallback
The WebViewSupport feature uses a pool dictionary called WebViewConstants to provide pool variables for constant values. For example, pool variables such as XmNnavigationCompletedCallback are used as arguments to CwWebView methods. These pool variable names should be used rather than directly using their constant values. All classes that require these WebViewConstants variable names must include the WebViewConstants pool dictionary in their class definition.
Examples
| shell form webView button rowColumn |
shell := CwTopLevelShell
createApplicationShell: 'shell'
argBlock: [:w | w title: 'Form Example'].
form := shell
createForm: 'form'
argBlock: nil.
form manageChild.
rowColumn := form
createRowColumn: 'buttons'
argBlock: nil.
rowColumn manageChild.
button := rowColumn
createPushButton: 'Top'
argBlock: nil.
button
addCallback: XmNactivateCallback
receiver: self
selector: #button:clientData:callData:
clientData: 'go'.
button manageChild.
webView := CwWebView createWidget: 'WebView'
parent: form argBlock: [:w | w
borderWidth: 1;
width: 400;
height: 200;
leftAttachment: XmATTACHFORM;
leftOffset: 2;
rightAttachment: XmATTACHFORM;
rightOffset: 2;
topAttachment: XmATTACHFORM;
topOffset: 40;
bottomAttachment: XmATTACHFORM;
bottomOffset: 2].
webView manageChild.
shell realizeWidget.
webView inspect.
"Here is the activate callback used in the code:"
button: widget clientData: clientData callData: callData
"A button has been pressed."
Transcript cr; show: 'The ', clientData, ' button has been pressed.'
webView setUrl: 'https://www.instantiations.com'
Last modified date: 02/06/2024