DataObject.IHandler

References
public interface DataObject.IHandler : Widget.IHandler, IDataObject
Handler interface for platform implementations of DataObject

Properties

ContainsHtml

bool ContainsHtml { get; }
Gets a value indicating whether this IDataObject contains a value for IDataObject.Html.
inherited fromIDataObject

ContainsImage

bool ContainsImage { get; }
Gets a value indicating whether this IDataObject contains a value for IDataObject.Image.
inherited fromIDataObject

ContainsText

bool ContainsText { get; }
Gets a value indicating whether this IDataObject contains a value for IDataObject.Text.
inherited fromIDataObject

ContainsUris

bool ContainsUris { get; }
Gets a value indicating whether this IDataObject contains a value for IDataObject.Uris.
inherited fromIDataObject
Remarks: This can be a mix of both URL and File objects. You can use Uri.IsFile to test for that. On some platforms, (e.g. windows), only a single URL can be retrieved or set.
true if the data object contains uris; otherwise, false.

Html

string Html { get; set; }
Gets or sets html text in the data object.
inherited fromIDataObject
The html value in the data object, or null if no html in the data object.

ID

string ID { get; set; }
Gets or sets an ID for the widget
inherited fromWidget.IHandler
Remarks: Some platforms may use this to identify controls (e.g. web)

Image

Image Image { get; set; }
Gets or sets an image in the data object.
inherited fromIDataObject
The image in the data object, or null if no image is in the data object.

NativeHandle

nint NativeHandle { get; }
Gets the native platform-specific handle for integration purposes
inherited fromWidget.IHandler

Text

string Text { get; set; }
Gets or sets the plain text in the data object.
inherited fromIDataObject
The plain text in the data object, or null if no plain text string in the data object.

Types

string[] Types { get; }
Gets the type id's for each type of data in the data object.
inherited fromIDataObject

Uris

Uri[] Uris { get; set; }
Gets or sets the Uri's of the files in the data object.
inherited fromIDataObject
Remarks: This can be a mix of both URL and File objects. You can use Uri.IsFile to test for that. On some platforms, (e.g. windows), only a single URL can be retrieved or set.
The uris of the files, or null if no files are in the data object.

Methods

Contains

bool Contains(string type)
Gets a value indicating that data with the specified type is contained in the data object.
inherited fromIDataObject
type (string)Type to test.
true if the data object contains the specified type, false otherwise.

GetData

byte[] GetData(string type)
Gets a data array from the data object with the specified type identifier.
inherited fromIDataObject
type (string)Type identifier that was used to store the data.
The data array, or null if not found in the data object.

GetObject

object GetObject(string type, Type objectType)
Gets an object from the data object with the specified type
inherited fromIDataObject
Remarks: This is useful when you know the type of object, and it is serializable or has a type converter to convert from string. If it cannot be converted it will return the default value.
type (string)Type identifier to get from the data object
objectType (Type)Type of the object to get, or null to detect type
An instance of the object to recieve, or the default value.

GetObject<T>

T GetObject<T>(string type)
Gets an object from the data object with the specified type
inherited fromIDataObject
Remarks: This is useful when you know the type of object, and it is serializable or has a type converter to convert from string. If it cannot be converted it will return the default value.
type (string)Type identifier to get from the data object
An instance of the object to recieve, or the default value.

GetString

string GetString(string type)
Gets a string from the data object with the specified type identifier.
inherited fromIDataObject

HandleEvent

void HandleEvent(string id, bool defaultEvent = false)
Called to handle a specific event
inherited fromWidget.IHandler
Remarks: Most events are late bound by this method. Instead of wiring all events, this will be called with an event string that is defined by the control. This is called automatically when attaching to events, but must be called manually when users of the control only override the event's On... method.
id (string)ID of the event to handle
defaultEvent (bool = false)True if the event is default (e.g. overridden or via an event handler subscription)

Initialize

void Initialize()
Called after the widget is constructed
inherited fromWidget.IHandler
Remarks: This gets called automatically after the control is constructed and the Widget.IHandler.Widget and Widget.Platform properties are set. When the handler has specialized construction methods, then the AutoInitializeAttribute can be used to disable automatic initialization. In this case, it is the responsibility of the subclass to call Widget.Initialize()

SetData

void SetData(byte[] value, string type)
sets a data array into the data object with the specified type identifier.
inherited fromIDataObject
value (byte[])Data to store in the data object.
type (string)Type identifier to store the data.

SetObject

void SetObject(object value, string type)
Sets the value into the data object with the specified type using serialization or type converter
inherited fromIDataObject
Remarks: The object specified must be serializable or have a type converter to convert to a string.
value (object)Serializable value to set as a value in the data object
type (string)Type identifier to set the value for

SetString

void SetString(string value, string type)
Sets a string into the data object with the specified type identifier.
inherited fromIDataObject
Remarks: This is useful when setting alternate string values into the data object that are not plain text. If you are storing plain text, use the IDataObject.Text property instead.
value (string)Value to set in the data object.
type (string)Type identifier that was used to store the data.

TryGetObject

#
bool TryGetObject(string type, Type objectType, out object value)
Attempts to get the specified value from the clipboard in a native-supplied way
type (string)Data format type to get the value
objectType (Type)Type that is requested, or null for any type
value (out object)Value returned
True if the value was returned, false otherwise

TrySetObject

#
bool TrySetObject(object value, string type)
Attempts to set the specified object to the clipboard in a native-supplied way
Remarks: This is used so native handlers can set certain objects in a particular way. For example, on macOS, setting a Color object for DataFormats.Color will use native API to set the value.
value (object)Value to set
type (string)Data format type
true if the native handler set the value, or false to fallback to serialization or conversion to string

UnhandleEvent

virtual void UnhandleEvent(string id)
Called when the last subscriber to an event has been removed, so the platform can stop listening for it.
inherited fromWidget.IHandler
Remarks: Only reached for events whose remove accessor uses PropertyStore.RemoveHandlerEvent(string, Delegate), and only for events that were attached because something subscribed to them. An event attached because the widget overrides its On[Event] method is never detached, since it has to keep firing regardless. Most events stay attached for the life of the widget, which costs nothing. Detaching is worth wiring up for the few that hold onto something expensive or process wide while they are attached, such as a system wide hook. Handlers deriving from WidgetHandler<TWidget> get an implementation of this that dispatches to WidgetHandler<TWidget>.DetachEvent(string), which is what to override.
id (string)ID of the event to stop handling