cohtml.ViewListener

A class that allows to listen for various events in the native View.

Inherits from cohtml.Net.IViewListener, SystemIDisposable

Public Events

Name
ActionBindingsReleased()
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.
ActionDOMBuilt()
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.
ActionReadyForBindings()
Invoked when the CohtmlView is ready to accept JavaScript bindings.
ActionScriptContextCreated()
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

Name
virtual override voidOnBindingsReleased()
Called when the JavaScript bindings of a CohtmlView component are released.
virtual override voidOnFinishLoad(string url)
Called when a page, including the resources it refers to, is completely loaded and initialized.
virtual override voidOnDOMBuilt()
Called when the page’s DOM is fully constructed, but the referenced resources may not have finished loading.
virtual override voidOnLoadFailed(string url, string error)
Called when a URL navigation change request failed.
virtual override boolOnNavigateTo(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 voidOnReadyForBindings()
Called when the CohtmlView is ready to accept JavaScript bindings.
virtual override voidOnScriptContextCreated()
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 ActionsOnNodeKeyEvent(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 ActionsOnNodeMouseEvent(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 ActionsOnNodeTouched(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 IClientSideSocketOnCreateWebSocket(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 voidOnClipboardTextSet(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 voidOnClipboardTextGet(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 voidOnAudioStreamCreated(int id, int bitDepth, int channels, float samplingRate)
Called by the UI when a media element initializes an audio stream.
override voidOnAudioDataReceived(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 voidOnAudioStreamPlay(int id)
Called by the UI when a media element starts playing an audio stream.
virtual override voidOnAudioStreamPause(int id)
Called by the UI when a playing media element pauses.
virtual override voidOnAudioStreamEnded(int id)
Called when an audio stream ends and will no longer receive data.
virtual override voidOnAudioStreamClosed(int id)
Called when an audio stream is destroyed.
virtual override voidOnAudioStreamVolumeChanged(int id, float volume)
Called when an audio stream volume has changed.

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

Public Classes inherited from cohtml.Net.IViewListener

Name
classIClipboardData
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 voidDispose()
IViewListener()
virtual InterceptRequestStatusOnResourceRequestIntercepted(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 ScreenInfoOnScreenInfoRequested()
Called when JavaScript requested screen metrics Returns current screen metrics.
virtual voidOnTextInputTypeChanged(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 voidOnCaretRectChanged(int x, int y, uint width, uint height)
Called when the caret changes during IME composition. You can use this method to correctly position a custom IME control & candidate list.
virtual voidOnCursorChanged(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 boolSwigDelegateIViewListener_0(string url, global.System.IntPtr swigId)
delegate intSwigDelegateIViewListener_1(string url, global.System.IntPtr swigId)
delegate voidSwigDelegateIViewListener_2(global.System.IntPtr swigId)
delegate voidSwigDelegateIViewListener_3(global.System.IntPtr swigId)
delegate voidSwigDelegateIViewListener_4(string url, string error, global.System.IntPtr swigId)
delegate voidSwigDelegateIViewListener_5(string url, global.System.IntPtr swigId)
delegate voidSwigDelegateIViewListener_6(global.System.IntPtr swigId)
delegate voidSwigDelegateIViewListener_7(global.System.IntPtr swigId)
delegate global.System.IntPtrSwigDelegateIViewListener_8(global.System.IntPtr swigId)
delegate intSwigDelegateIViewListener_9(global.System.IntPtr node, global.System.IntPtr arg1, global.System.IntPtr userData, int phase, global.System.IntPtr swigId)
delegate intSwigDelegateIViewListener_10(global.System.IntPtr node, global.System.IntPtr arg1, global.System.IntPtr userData, int phase, global.System.IntPtr swigId)
delegate intSwigDelegateIViewListener_11(global.System.IntPtr node, global.System.IntPtr arg1, global.System.IntPtr userData, int phase, global.System.IntPtr swigId)
delegate voidSwigDelegateIViewListener_12(int id, int bitDepth, int channels, float samplingRate, global.System.IntPtr swigId)
delegate voidSwigDelegateIViewListener_13(int id, global.System.IntPtr swigId)
delegate voidSwigDelegateIViewListener_14(int id, global.System.IntPtr swigId)
delegate voidSwigDelegateIViewListener_15(int id, global.System.IntPtr swigId)
delegate voidSwigDelegateIViewListener_16(int id, int samples, System.IntPtr pcm, int channels, global.System.IntPtr swigId)
delegate voidSwigDelegateIViewListener_17(int id, global.System.IntPtr swigId)
delegate voidSwigDelegateIViewListener_18(int id, float volume, global.System.IntPtr swigId)
delegate voidSwigDelegateIViewListener_19(int type, global.System.IntPtr swigId)
delegate voidSwigDelegateIViewListener_20(int x, int y, uint width, uint height, global.System.IntPtr swigId)
delegate voidSwigDelegateIViewListener_21(int cursor, string url, System.IntPtr xHotspot, System.IntPtr yHotspot, global.System.IntPtr swigId)
delegate voidSwigDelegateIViewListener_22(string text, uint lengthBytes, global.System.IntPtr swigId)
delegate voidSwigDelegateIViewListener_23(global.System.IntPtr setDataObject, global.System.IntPtr swigId)
delegate global.System.IntPtrSwigDelegateIViewListener_24(global.System.IntPtr listener, string url, System.IntPtr protocols, uint protocolsCount, global.System.IntPtr swigId)

Protected Attributes inherited from cohtml.Net.IViewListener

Name
boolswigCMemOwn

Public Events Documentation

event BindingsReleased

Action BindingsReleased()

Invoked when the JavaScript bindings of a CohtmlView are released.

event FinishLoad

Action< string > FinishLoad()

Invoked when a page, including the resources it refers to, is completely loaded and initialized.

event DOMBuilt

Action DOMBuilt()

Invoked when the page’s DOM is fully constructed, but the referenced resources may not have finished loading.

event LoadFailed

Action< string, string > LoadFailed()

Invoked when a URL navigation change request failed.

event ReadyForBindings

Action ReadyForBindings()

Invoked when the CohtmlView is ready to accept JavaScript bindings.

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

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

function OnBindingsReleased

virtual override void OnBindingsReleased()

Called when the JavaScript bindings of a CohtmlView component are released.

Reimplements: cohtml.Net.IViewListener.OnBindingsReleased

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

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

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

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

virtual override void OnReadyForBindings()

Called when the CohtmlView is ready to accept JavaScript bindings.

Reimplements: cohtml.Net.IViewListener.OnReadyForBindings

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

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

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

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

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

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

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

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

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

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

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

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

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

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

property OnAudioStreamCreate

Action< int, int, int, float > OnAudioStreamCreate;

Invoked when a media element in the UI initializes an audio stream.

property OnAudioDataReceive

Action< int, int, IntPtr, int > OnAudioDataReceive;

Invoked when there is decoded PCM data available for playing.

property OnAudioStreamPlayed

Action< int > OnAudioStreamPlayed;

Invoked when a media element starts playing an audio stream.

property OnAudioStreamPaused

Action< int > OnAudioStreamPaused;

Invoked when a playing media element pauses.

property OnAudioStreamVolumeChange

Action< int, float > OnAudioStreamVolumeChange;

Invoked when an audio stream volume has changed.

property OnAudioStreamEnds

Action< int > OnAudioStreamEnds;

Invoked when an audio stream ends and will no longer receive data.

property OnAudioStreamClose

Action< int > OnAudioStreamClose;

Invoked when an audio stream is destroyed.

property OnWebsocketStateChanged

Action< WebSocketState > OnWebsocketStateChanged;

A callback that provides the current status of the WebSocket.

property OnWebsocketTimeoutSet

Func< int > OnWebsocketTimeoutSet;

A callback that set the WebSocket timeout.