cohtml.ViewListener
A class that allows to listen for various events in the native View.
Inherits from cohtml.Net.IViewListener, SystemIDisposable
Public Events
Section titled “Public Events”| Name | |
|---|---|
| Action | BindingsReleased() Invoked when the JavaScript bindings of a CohtmlView are released. |
| Action< string > | FinishLoad() Invoked when a page, including the resources it refers to, is completely loaded and initialized. |
| Action | DOMBuilt() Invoked when the page’s DOM is fully constructed, but the referenced resources may not have finished loading. |
| Action< string, string > | LoadFailed() Invoked when a URL navigation change request failed. |
| Action | ReadyForBindings() Invoked when the CohtmlView is ready to accept JavaScript bindings. |
| Action | ScriptContextCreated() Invoked immediately after the script context has been created for the page. This happens before starting to build the DOM. Execute any scripts that will influence DOM creation here. |
| Func< string, bool > | NavigateTo() Invoked when a navigation is about to occur. The user is able to interrupt the navigation or let it continue normally. |
Public Functions
Section titled “Public Functions”| Name | |
|---|---|
| virtual override void | OnBindingsReleased() Called when the JavaScript bindings of a CohtmlView component are released. |
| virtual override void | OnFinishLoad(string url) Called when a page, including the resources it refers to, is completely loaded and initialized. |
| virtual override void | OnDOMBuilt() Called when the page’s DOM is fully constructed, but the referenced resources may not have finished loading. |
| virtual override void | OnLoadFailed(string url, string error) Called when a URL navigation change request failed. |
| virtual override bool | OnNavigateTo(string url) Called when a navigation is about to occur. The user is able to interrupt the navigation or let it continue normally. Returns ‘true’ when the navigation is successful and ‘false’ when it fails. |
| virtual override void | OnReadyForBindings() Called when the CohtmlView is ready to accept JavaScript bindings. |
| virtual override void | OnScriptContextCreated() Called immediately after the script context has been created for the page. This happens before starting to build the DOM. Execute any scripts that will influence DOM creation here. |
| override Actions | OnNodeKeyEvent(INodeProxy node, IKeyEventData eventData, IntPtr userData, PhaseType phase) Called before an event is passed to a DOM node for evaluation. The user is able to interrupt the handling and bubbling of events or let them continue normally. |
| override Actions | OnNodeMouseEvent(INodeProxy node, IMouseEventData eventData, IntPtr userData, PhaseType phase) Called before an event is passed to a DOM node for evaluation. The user is able to interrupt the handling and bubbling of events or let them continue normally. |
| override Actions | OnNodeTouched(INodeProxy node, ITouchEventData eventData, IntPtr userData, PhaseType phase) Called before an event is passed to a DOM node for evaluation. The user is able to interrupt the handling and bubbling of events or let them continue normally. |
| override IClientSideSocket | OnCreateWebSocket(ISocketListener listener, string url, IntPtr protocolsPtr, uint protocolsCount) Called when the CohtmlView tries to establish a web socket connection. When JS tries to create a new web sockets it will create a new cohtml.Net.ISocketListener in the CohtmlView. OnCreateWebSocket will be called after that and it must respond with a cohtml.Net.IClientSideSocket object which represent the socket implementation for the current platform. |
| virtual override void | OnClipboardTextSet(string text, uint lengthBytes) Called when the user has initiated an operation of putting data in the Clipboard (copy or cut). The implementer must communicate with the OS API and set the passed data in the Clipboard. |
| override void | OnClipboardTextGet(IClipboardData setDataObject) Called when the user has initiated an operation that recovers data from the clipboard (paste). The implementer should get the text from the clipboard with the OS API and call the passed callback to set the data. Note: The setDataObject is only valid in the call-stack of this method! |
| virtual override void | OnAudioStreamCreated(int id, int bitDepth, int channels, float samplingRate) Called by the UI when a media element initializes an audio stream. |
| override void | OnAudioDataReceived(int id, int samples, IntPtr pcm, int channels) Called by the UI when there is decoded Pulse Code Modulation data available for playing. |
| virtual override void | OnAudioStreamPlay(int id) Called by the UI when a media element starts playing an audio stream. |
| virtual override void | OnAudioStreamPause(int id) Called by the UI when a playing media element pauses. |
| virtual override void | OnAudioStreamEnded(int id) Called when an audio stream ends and will no longer receive data. |
| virtual override void | OnAudioStreamClosed(int id) Called when an audio stream is destroyed. |
| virtual override void | OnAudioStreamVolumeChanged(int id, float volume) Called when an audio stream volume has changed. |
Public Properties
Section titled “Public Properties”| Name | |
|---|---|
| Action< int, int, int, float > | OnAudioStreamCreate Invoked when a media element in the UI initializes an audio stream. |
| Action< int, int, IntPtr, int > | OnAudioDataReceive Invoked when there is decoded PCM data available for playing. |
| Action< int > | OnAudioStreamPlayed Invoked when a media element starts playing an audio stream. |
| Action< int > | OnAudioStreamPaused Invoked when a playing media element pauses. |
| Action< int, float > | OnAudioStreamVolumeChange Invoked when an audio stream volume has changed. |
| Action< int > | OnAudioStreamEnds Invoked when an audio stream ends and will no longer receive data. |
| Action< int > | OnAudioStreamClose Invoked when an audio stream is destroyed. |
| Action< WebSocketState > | OnWebsocketStateChanged A callback that provides the current status of the WebSocket. |
| Func< int > | OnWebsocketTimeoutSet A callback that set the WebSocket timeout. |
Additional inherited members
Section titled “Additional inherited members”Public Classes inherited from cohtml.Net.IViewListener
| Name | |
|---|---|
| class | IClipboardData The class should be used by the implementer to set the data recovered from the clipboard. Use this class only in the context of a ViewListener.OnClipboardTextGet call. |
Public Functions inherited from cohtml.Net.IViewListener
| Name | |
|---|---|
| virtual void | Dispose() |
| IViewListener() | |
| virtual InterceptRequestStatus | OnResourceRequestIntercepted(string url) Only used when View.InterceptResourceRequests is explicitly set to true. Called before sending a request to load a resource from the specified url. |
| virtual ScreenInfo | OnScreenInfoRequested() Called when JavaScript requested screen metrics Returns current screen metrics. |
| virtual void | OnTextInputTypeChanged(ControlType type) Called when the current text input control changes (i.e. the user click an edit-box). Use this method to decide when to allow for IME input. |
| virtual void | OnCaretRectChanged(int x, int y, uint width, uint height) Called when the caret changes its size or position. That includes moving the caret during IME composition. You can use this method to correctly position a custom IME control & candidate list. |
| virtual void | OnCursorChanged(Cursors cursor, string url, System.IntPtr xHotspot, System.IntPtr yHotspot) Called when the cursor under the pointer changes. The user should modify the visible cursor from the OS to reflect the change. |
| delegate bool | SwigDelegateIViewListener_0(string url, global.System.IntPtr swigId) |
| delegate int | SwigDelegateIViewListener_1(string url, global.System.IntPtr swigId) |
| delegate void | SwigDelegateIViewListener_2(global.System.IntPtr swigId) |
| delegate void | SwigDelegateIViewListener_3(global.System.IntPtr swigId) |
| delegate void | SwigDelegateIViewListener_4(string url, string error, global.System.IntPtr swigId) |
| delegate void | SwigDelegateIViewListener_5(string url, global.System.IntPtr swigId) |
| delegate void | SwigDelegateIViewListener_6(global.System.IntPtr swigId) |
| delegate void | SwigDelegateIViewListener_7(global.System.IntPtr swigId) |
| delegate global.System.IntPtr | SwigDelegateIViewListener_8(global.System.IntPtr swigId) |
| delegate int | SwigDelegateIViewListener_9(global.System.IntPtr node, global.System.IntPtr arg1, global.System.IntPtr userData, int phase, global.System.IntPtr swigId) |
| delegate int | SwigDelegateIViewListener_10(global.System.IntPtr node, global.System.IntPtr arg1, global.System.IntPtr userData, int phase, global.System.IntPtr swigId) |
| delegate int | SwigDelegateIViewListener_11(global.System.IntPtr node, global.System.IntPtr arg1, global.System.IntPtr userData, int phase, global.System.IntPtr swigId) |
| delegate void | SwigDelegateIViewListener_12(int id, int bitDepth, int channels, float samplingRate, global.System.IntPtr swigId) |
| delegate void | SwigDelegateIViewListener_13(int id, global.System.IntPtr swigId) |
| delegate void | SwigDelegateIViewListener_14(int id, global.System.IntPtr swigId) |
| delegate void | SwigDelegateIViewListener_15(int id, global.System.IntPtr swigId) |
| delegate void | SwigDelegateIViewListener_16(int id, int samples, System.IntPtr pcm, int channels, global.System.IntPtr swigId) |
| delegate void | SwigDelegateIViewListener_17(int id, global.System.IntPtr swigId) |
| delegate void | SwigDelegateIViewListener_18(int id, float volume, global.System.IntPtr swigId) |
| delegate void | SwigDelegateIViewListener_19(int type, global.System.IntPtr swigId) |
| delegate void | SwigDelegateIViewListener_20(int x, int y, uint width, uint height, global.System.IntPtr swigId) |
| delegate void | SwigDelegateIViewListener_21(int cursor, string url, System.IntPtr xHotspot, System.IntPtr yHotspot, global.System.IntPtr swigId) |
| delegate void | SwigDelegateIViewListener_22(string text, uint lengthBytes, global.System.IntPtr swigId) |
| delegate void | SwigDelegateIViewListener_23(global.System.IntPtr setDataObject, global.System.IntPtr swigId) |
| delegate global.System.IntPtr | SwigDelegateIViewListener_24(global.System.IntPtr listener, string url, System.IntPtr protocols, uint protocolsCount, global.System.IntPtr swigId) |
Protected Attributes inherited from cohtml.Net.IViewListener
| Name | |
|---|---|
| bool | swigCMemOwn |
Public Events Documentation
Section titled “Public Events Documentation”event BindingsReleased
Section titled “event BindingsReleased”Action BindingsReleased()Invoked when the JavaScript bindings of a CohtmlView are released.
event FinishLoad
Section titled “event FinishLoad”Action< string > FinishLoad()Invoked when a page, including the resources it refers to, is completely loaded and initialized.
event DOMBuilt
Section titled “event DOMBuilt”Action DOMBuilt()Invoked when the page’s DOM is fully constructed, but the referenced resources may not have finished loading.
event LoadFailed
Section titled “event LoadFailed”Action< string, string > LoadFailed()Invoked when a URL navigation change request failed.
event ReadyForBindings
Section titled “event ReadyForBindings”Action ReadyForBindings()Invoked when the CohtmlView is ready to accept JavaScript bindings.
event ScriptContextCreated
Section titled “event ScriptContextCreated”Action ScriptContextCreated()Invoked immediately after the script context has been created for the page. This happens before starting to build the DOM. Execute any scripts that will influence DOM creation here.
event NavigateTo
Section titled “event NavigateTo”Func< string, bool > NavigateTo()Invoked when a navigation is about to occur. The user is able to interrupt the navigation or let it continue normally.
Public Functions Documentation
Section titled “Public Functions Documentation”function OnBindingsReleased
Section titled “function OnBindingsReleased”virtual override void OnBindingsReleased()Called when the JavaScript bindings of a CohtmlView component are released.
Reimplements: cohtml.Net.IViewListener.OnBindingsReleased
function OnFinishLoad
Section titled “function OnFinishLoad”virtual override void OnFinishLoad( string url)Called when a page, including the resources it refers to, is completely loaded and initialized.
Parameters:
- url The URL of your HTML page.
Reimplements: cohtml.Net.IViewListener.OnFinishLoad
function OnDOMBuilt
Section titled “function OnDOMBuilt”virtual override void OnDOMBuilt()Called when the page’s DOM is fully constructed, but the referenced resources may not have finished loading.
Reimplements: cohtml.Net.IViewListener.OnDOMBuilt
function OnLoadFailed
Section titled “function OnLoadFailed”virtual override void OnLoadFailed( string url, string error)Called when a URL navigation change request failed.
Parameters:
- url The URL of your HTML page.
- error A description of the error.
Reimplements: cohtml.Net.IViewListener.OnLoadFailed
function OnNavigateTo
Section titled “function OnNavigateTo”virtual override bool OnNavigateTo( string url)Called when a navigation is about to occur. The user is able to interrupt the navigation or let it continue normally. Returns ‘true’ when the navigation is successful and ‘false’ when it fails.
Parameters:
- url The URL of your HTML page.
Reimplements: cohtml.Net.IViewListener.OnNavigateTo
function OnReadyForBindings
Section titled “function OnReadyForBindings”virtual override void OnReadyForBindings()Called when the CohtmlView is ready to accept JavaScript bindings.
Reimplements: cohtml.Net.IViewListener.OnReadyForBindings
function OnScriptContextCreated
Section titled “function OnScriptContextCreated”virtual override void OnScriptContextCreated()Called immediately after the script context has been created for the page. This happens before starting to build the DOM. Execute any scripts that will influence DOM creation here.
Reimplements: cohtml.Net.IViewListener.OnScriptContextCreated
function OnNodeKeyEvent
Section titled “function OnNodeKeyEvent”override Actions OnNodeKeyEvent( INodeProxy node, IKeyEventData eventData, IntPtr userData, PhaseType phase)Called before an event is passed to a DOM node for evaluation. The user is able to interrupt the handling and bubbling of events or let them continue normally.
Parameters:
- node The node to which the event is passed to.
- eventData Contains data about the event.
- userData A pointer that you can fill with custom data.
- phase The current PhaseType of the event.
Return: An enum constant whether the native library should continue handling or interrupt the event.
function OnNodeMouseEvent
Section titled “function OnNodeMouseEvent”override Actions OnNodeMouseEvent( INodeProxy node, IMouseEventData eventData, IntPtr userData, PhaseType phase)Called before an event is passed to a DOM node for evaluation. The user is able to interrupt the handling and bubbling of events or let them continue normally.
Parameters:
- node The node to which the event is passed to.
- eventData Contains data about the event.
- userData A pointer that you can fill with custom data.
- phase The current PhaseType of the event.
Return: An enum constant whether the native library should continue handling or interrupt the event.
function OnNodeTouched
Section titled “function OnNodeTouched”override Actions OnNodeTouched( INodeProxy node, ITouchEventData eventData, IntPtr userData, PhaseType phase)Called before an event is passed to a DOM node for evaluation. The user is able to interrupt the handling and bubbling of events or let them continue normally.
Parameters:
- node The node to which the event is passed to.
- eventData Contains data about the event.
- userData A pointer that you can fill with custom data.
- phase The current PhaseType of the event.
Return: An enum constant whether the native library should continue handling or interrupt the event.
function OnCreateWebSocket
Section titled “function OnCreateWebSocket”override IClientSideSocket OnCreateWebSocket( ISocketListener listener, string url, IntPtr protocolsPtr, uint protocolsCount)Called when the CohtmlView tries to establish a web socket connection. When JS tries to create a new web sockets it will create a new cohtml.Net.ISocketListener in the CohtmlView. OnCreateWebSocket will be called after that and it must respond with a cohtml.Net.IClientSideSocket object which represent the socket implementation for the current platform.
Parameters:
- listener The native side of the connection, use side must use it to communicate with the CohtmlView.
- url The URL to which to connect; this should be the URL to which the WebSocket server will respond.
- protocolsPtr Either a single protocol string or an array of protocol strings. These strings are used to indicate sub-protocols, so that a single server can implement multiple WebSocket sub-protocols (for example, you might want one server to be able to handle different types of interactions depending on the specified protocol). If you don’t specify a protocol string, an empty string is assumed.
- protocolsCount The number of protocols passed
Return: The cohtml.Net.IClientSideSocket interface which could also be your own implementation.
function OnClipboardTextSet
Section titled “function OnClipboardTextSet”virtual override void OnClipboardTextSet( string text, uint lengthBytes)Called when the user has initiated an operation of putting data in the Clipboard (copy or cut). The implementer must communicate with the OS API and set the passed data in the Clipboard.
Parameters:
- text The text bytes (UTF-8) that the user is trying to copy in the clipboard.
- lengthBytes The length in bytes of the text passed.
Reimplements: cohtml.Net.IViewListener.OnClipboardTextSet
function OnClipboardTextGet
Section titled “function OnClipboardTextGet”override void OnClipboardTextGet( IClipboardData setDataObject)Called when the user has initiated an operation that recovers data from the clipboard (paste). The implementer should get the text from the clipboard with the OS API and call the passed callback to set the data. Note: The setDataObject is only valid in the call-stack of this method!
Parameters:
- setDataObject Set function that must be called with the data recovered from the clipboard.
function OnAudioStreamCreated
Section titled “function OnAudioStreamCreated”virtual override void OnAudioStreamCreated( int id, int bitDepth, int channels, float samplingRate)Called by the UI when a media element initializes an audio stream.
Parameters:
- id The unique identification number of the stream.
- bitDepth The number of bits per audio sample.
- channels The number of channels in the stream.
- samplingRate The sampling rate of the stream in Hz.
Reimplements: cohtml.Net.IViewListener.OnAudioStreamCreated
function OnAudioDataReceived
Section titled “function OnAudioDataReceived”override void OnAudioDataReceived( int id, int samples, IntPtr pcm, int channels)Called by the UI when there is decoded Pulse Code Modulation data available for playing.
Parameters:
- id The unique identification number of the stream.
- samples The number of available samples.
- pcm The decoded Pulse Code Modulation data represented as a 2D array with |channels| x |samples| floating point elements in the range [-1, 1].
- channels The number of channels.
function OnAudioStreamPlay
Section titled “function OnAudioStreamPlay”virtual override void OnAudioStreamPlay( int id)Called by the UI when a media element starts playing an audio stream.
Parameters:
- id The unique identification number of the stream.
Reimplements: cohtml.Net.IViewListener.OnAudioStreamPlay
function OnAudioStreamPause
Section titled “function OnAudioStreamPause”virtual override void OnAudioStreamPause( int id)Called by the UI when a playing media element pauses.
Parameters:
- id The unique identification number of the stream.
Reimplements: cohtml.Net.IViewListener.OnAudioStreamPause
function OnAudioStreamEnded
Section titled “function OnAudioStreamEnded”virtual override void OnAudioStreamEnded( int id)Called when an audio stream ends and will no longer receive data.
Parameters:
- id The unique identification number of the stream.
Reimplements: cohtml.Net.IViewListener.OnAudioStreamEnded
function OnAudioStreamClosed
Section titled “function OnAudioStreamClosed”virtual override void OnAudioStreamClosed( int id)Called when an audio stream is destroyed.
Parameters:
- id The unique identification number of the stream.
Reimplements: cohtml.Net.IViewListener.OnAudioStreamClosed
function OnAudioStreamVolumeChanged
Section titled “function OnAudioStreamVolumeChanged”virtual override void OnAudioStreamVolumeChanged( int id, float volume)Called when an audio stream volume has changed.
Parameters:
- id The unique identification number of the stream.
- volume The new value of the volume.
Reimplements: cohtml.Net.IViewListener.OnAudioStreamVolumeChanged
Public Property Documentation
Section titled “Public Property Documentation”property OnAudioStreamCreate
Section titled “property OnAudioStreamCreate”Action< int, int, int, float > OnAudioStreamCreate;Invoked when a media element in the UI initializes an audio stream.
property OnAudioDataReceive
Section titled “property OnAudioDataReceive”Action< int, int, IntPtr, int > OnAudioDataReceive;Invoked when there is decoded PCM data available for playing.
property OnAudioStreamPlayed
Section titled “property OnAudioStreamPlayed”Action< int > OnAudioStreamPlayed;Invoked when a media element starts playing an audio stream.
property OnAudioStreamPaused
Section titled “property OnAudioStreamPaused”Action< int > OnAudioStreamPaused;Invoked when a playing media element pauses.
property OnAudioStreamVolumeChange
Section titled “property OnAudioStreamVolumeChange”Action< int, float > OnAudioStreamVolumeChange;Invoked when an audio stream volume has changed.
property OnAudioStreamEnds
Section titled “property OnAudioStreamEnds”Action< int > OnAudioStreamEnds;Invoked when an audio stream ends and will no longer receive data.
property OnAudioStreamClose
Section titled “property OnAudioStreamClose”Action< int > OnAudioStreamClose;Invoked when an audio stream is destroyed.
property OnWebsocketStateChanged
Section titled “property OnWebsocketStateChanged”Action< WebSocketState > OnWebsocketStateChanged;A callback that provides the current status of the WebSocket.
property OnWebsocketTimeoutSet
Section titled “property OnWebsocketTimeoutSet”Func< int > OnWebsocketTimeoutSet;A callback that set the WebSocket timeout.
© 2026 Coherent Labs. All rights reserved.