Remarks: This allows a single implementation to be used in multiple platforms and is useful in a couple of scenarios: a) Creating default implementations of a control on platforms that do not support the control natively. b) Implementing a control with a non-native look and feel that is consistent across platforms.
TControlThe Eto control used to create the custom implementation, e.g. Panel where Control
TWidgetThe control being implemented, e.g. TabControl where Control
TCallbackThe callback inferface for the control, e.g. TabControl.ICallback where Control.ICallback

Properties

AllowDrop

#
public virtual bool AllowDrop { get; set; }
Gets or sets a value indicating whether this control can serve as drop target.

BackgroundColor

#
public virtual Color BackgroundColor { get; set; }
Gets or sets the color for the background of the control
Remarks: Note that on some platforms (e.g. Mac), setting the background color of a control can change the performance characteristics of the control and its children, since it must enable layers to do so.
The color of the background.
BackgroundColor

Callback

public TCallback Callback { get; }
Gets the callback object for the control
inherited fromWidgetHandler<TControl, TWidget, TCallback>
Remarks: This object is typically a single static instance that is used by the platform handlers to call private or protected methods on the widget, such as protected event methods e.g. protected virtual void OnClick(EventArgs e)
The callback.

Connector

protected WidgetHandler<TControl, TWidget>.WeakConnector Connector { get; }
Gets a weak connector class to hook up events to the underlying control
inherited fromWidgetHandler<TControl, TWidget>
Remarks: Some frameworks (e.g. gtk, monomac, ios, android) keep track of references in a way that leak objects when there is a circular reference between the control and the handler. This is the case when registering events from the control to a method implemented in the handler. This instance can be used to connect the objects together using a weak reference to the handler, allowing controls to be garbage collected.
The connector instance

ContextMenu

#Since v2.10
public ContextMenu ContextMenu { get; set; }
Gets or sets the context menu to show when the user right clicks or presses the menu key

ControlObject

#
public virtual object ControlObject { get; }
Gets the instance of the platform-specific object

Cursor

#
public virtual Cursor Cursor { get; set; }
Gets or sets the type of cursor to use when the mouse is hovering over the control

DisposeControl

protected virtual bool DisposeControl { get; }
Gets a value indicating that control should automatically be disposed when this widget is disposed
inherited fromWidgetHandler<TControl, TWidget>

Enabled

#
public virtual bool Enabled { get; set; }
Gets or sets a value indicating whether this control is enabled

FocusControl

#
protected virtual Control FocusControl { get; }
Gets the control used to attach focus events.

HasControl

public bool HasControl { get; }
Gets a value indicating whether this instance has a WidgetHandler<TControl, TWidget>.Control instance.
inherited fromWidgetHandler<TControl, TWidget>

HasFocus

#
public virtual bool HasFocus { get; }
Gets a value indicating whether this instance has the keyboard input focus.

Height

#
public virtual int Height { get; set; }
Gets or sets the height of the control size.

IsMouseCaptured

#
public bool IsMouseCaptured { get; }
Gets a value indicating this control currently has mouse capture
Remarks: Mouse capture can happen during a handled MouseDown event until MouseUp, or it can be captured explicitly via Control.IHandler.CaptureMouse().
IsMouseCaptured

KeyboardControl

#
protected virtual Control KeyboardControl { get; }
Gets the control used to attach keyboard and text input events

Location

#
public virtual Point Location { get; }
Gets the location of the control as positioned by the container
Remarks: A control's location is set by the container. This can be used to determine where the control is for overlaying floating windows, menus, etc.
The current location of the control
Location

MouseControl

#
protected virtual Control MouseControl { get; }
Gets the control used to attach mouse events

NativeHandle

public virtual nint NativeHandle { get; }
Gets the native platform-specific handle for integration purposes
inherited fromWidgetHandler<TWidget>

PropagateLoadEvents

#
public virtual bool PropagateLoadEvents { get; }
Gets a value indicating whether Control.PreLoad/Control.Load/Control.LoadComplete/Control.UnLoad events are propagated to the inner control
Remarks: Typically this should be true so that the events are propagated, but when you set the control hierarchy manually, such as a TabPage on a TabControl, you can return false here since the load events will be handled automatically by the internal eto controls.
true if propagate load events; otherwise, false.

Size

#
public virtual Size Size { get; set; }
Gets or sets the size of the control. Use -1 to specify auto sizing for either the width and/or height.

SupportedPlatformCommands

#
public virtual IEnumerable<string> SupportedPlatformCommands { get; }
Gets the supported platform commands that can be used to hook up system functions to user defined logic

TabIndex

#
public int TabIndex { get; set; }
Gets or sets the tab index order for this control within its container.
Remarks: This sets the order when using the tab key to cycle through controls Note that some platforms (Gtk and WinForms) may not support setting the context of the tab order to StackLayout or DynamicLayout containers and may not behave exactly as expected. Use the PlatformFeatures.TabIndexWithCustomContainers flag to determine if it is supported.
The index of the control in the tab order.
TabIndex

TabStop

#Since v2.12
public virtual bool TabStop { get; set; }
Gets or sets a value indicating whether the user can get to this control using the tab key.
true to include the control in the tab order (the default); false to skip it.
TabStop

ToolTip

#
public virtual string ToolTip { get; set; }
Gets or sets the tool tip to show when the mouse is hovered over the control

Visible

#
public virtual bool Visible { get; set; }
Gets or sets a value indicating whether this control is visible to the user.
Remarks: When the visibility of a control is set to false, it will still occupy space in the layout, but not be shown. The only exception is for controls like the Splitter, which will hide a pane if the visibility of one of the panels is changed.
true if visible; otherwise, false.
Visible

VisualControls

#
public virtual IEnumerable<Control> VisualControls { get; }
Gets an enumeration of controls that are in the visual tree.
Remarks: This is used to specify which controls are contained by this instance that are part of the visual tree. This should include all controls including non-logical Eto controls used for layout.
The visual controls.
VisualControls

Widget

public TWidget Widget { get; }
Gets the widget that this platform handler is attached to
inherited fromWidgetHandler<TWidget>

Width

#
public virtual int Width { get; set; }
Gets or sets the width of the control size.

Methods

AddGesture

#Since v2.12
public virtual void AddGesture(Gesture item)
Adds a gesture to the control.

AttachEvent

#
public override void AttachEvent(string id)
Attaches the specified event to the platform-specific control
Remarks: Implementors should override this method to handle any events that the widget supports. Ensure to call the base class' implementation if the event is not one the specific widget supports, so the base class' events can be handled as well.
id (string)Identifier of the event

CaptureMouse

#
public bool CaptureMouse()
Captures all mouse events to this control.
Remarks: This captures all mouse events until Control.IHandler.ReleaseMouseCapture() is called. Note that not all platforms will allow a mouse capture unless the mouse is currently down.
true if the mouse was captured, false otherwise.
CaptureMouse

ClearGestures

#Since v2.12
public virtual void ClearGestures()
Removes all gestures from the control.

CreateConnector

protected virtual WidgetHandler<TControl, TWidget>.WeakConnector CreateConnector()
Creates the event connector for this control
inherited fromWidgetHandler<TControl, TWidget>
Remarks: This creates the weak connector to use for event registration and other purposes.

CreateControl

protected virtual TControl CreateControl()
Creates the control if not already set.
inherited fromWidgetHandler<TControl, TWidget>
Remarks: Override this to create the control instance for the handler. This makes it easy to extend existing handler implementations with different control implementations. Some platforms (e.g. Mac) require subclasses to implement/override functionality.
The control.

DetachEvent

public virtual bool DetachEvent(string id)
Detaches an event from the platform-specific control, undoing WidgetHandler<TWidget>.AttachEvent(string).
inherited fromWidgetHandler<TWidget>
Remarks: Implementors can override this for events that hold onto something worth giving back while they are attached, such as a system wide hook. Most events cost nothing to leave attached for the life of the widget, which is why the default is to refuse. Only reached for events whose remove accessor uses PropertyStore.RemoveHandlerEvent(string, Delegate), and never for an event that is attached because the widget overrides its On[Event] method.
id (string)Identifier of the event
True if the event was detached, false if this platform can't detach it, in which case it stays attached and won't be attached again on a later subscription.

Dispose

protected override void Dispose(bool disposing)
Disposes this widget and the associated control if WidgetHandler<TControl, TWidget>.DisposeControl is true
inherited fromWidgetHandler<TControl, TWidget>

DoDragDrop

#
public void DoDragDrop(DataObject data, DragEffects allowedAction, Image image, PointF cursorOffset)
Starts drag operation using this control as drag source.
data (DataObject)Drag data.
allowedAction (DragEffects)Allowed action.
image (Image)Custom drag image
cursorOffset (PointF)Offset of the cursor to the drag image
DoDragDrop

Focus

#
public virtual void Focus()
Attempts to set the keyboard input focus to this control, or the first child that accepts focus

GetNativeParentWindow

#
public Window GetNativeParentWindow()
Gets the window this control is contained in

GetPreferredSize

#
public virtual SizeF GetPreferredSize(SizeF availableSize)
Gets the preferred size of this control given the specified availableSize.
availableSize (SizeF)The available size to determine the preferred size
The preferred size this control would like to be, which can be larger than the specified availableSize.
GetPreferredSize

HandleEvent

public void HandleEvent(string id, bool defaultEvent = false)
Called to handle a specific event
inherited fromWidgetHandler<TWidget>
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. Override the WidgetHandler<TWidget>.AttachEvent(string) to attach your events
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)
HandleEvent

Initialize

#
protected override void Initialize()
Called to initialize this widget after it has been constructed
Remarks: Override this to initialize any of the platform objects. This is called in the widget constructor, after all of the widget's constructor code has been called.

Invalidate

#
public virtual void Invalidate(bool invalidateChildren)
Queues a repaint of the entire control on the screen
Remarks: This is only useful when the control is visible.
invalidateChildren (bool)True to invalidate all children, false to only invalidate the container
Invalidate

Invalidate

#
public virtual void Invalidate(Rectangle rect, bool invalidateChildren)
Queues a repaint of the specified rect of the control
Remarks: This is only useful when the control is visible.
rect (Rectangle)Rectangle to repaint
invalidateChildren (bool)True to invalidate all children, false to only invalidate the container
Invalidate

IsEventHandled

public bool IsEventHandled(string id)
Gets a value indicating that the specified event is handled
inherited fromWidgetHandler<TWidget>
id (string)Identifier of the event
True if the event is handled, otherwise false

MapPlatformCommand

#
public virtual void MapPlatformCommand(string systemAction, Command action)
Specifies a command to execute for a platform-specific command

OnInitializeComplete

protected virtual void OnInitializeComplete()
Called after initialization is complete
inherited fromWidgetHandler<TWidget>
Remarks: Override this to perform any logic after the handler is fully initialized, but before returning from the construction of the widget. This by default applies the any styles for the handler.

OnLoadComplete

#
public virtual void OnLoadComplete(EventArgs e)
Called after all other controls have been loaded

OnUnLoad

#
public virtual void OnUnLoad(EventArgs e)
Called when the control is unloaded, which is when it is not currently on a displayed window

PointFromScreen

#
public virtual PointF PointFromScreen(PointF point)
Converts a point from screen space to control space.

PointToScreen

#
public virtual PointF PointToScreen(PointF point)
Converts a point from control space to screen space

RemoveGesture

#Since v2.12
public virtual void RemoveGesture(Gesture item)
Removes a gesture from the control.

ResumeLayout

#
public virtual void ResumeLayout()
Resumes the layout after it has been suspended, and performs a layout
Remarks: This can be used to optimize some platforms while adding, removing, or changing many child controls at once. Each call to ResumeLayout() must be balanced with a call to SuspendLayout() before it.
ResumeLayout

SetParent

#
public virtual void SetParent(Container oldParent, Container newParent)
Called when the parent of the control has been set
oldParent (Container)Old parent for the control, or null if the control is added
newParent (Container)New parent for the control, or null if the parent was removed
SetParent

SuspendLayout

#
public virtual void SuspendLayout()
Suspends the layout of child controls
Remarks: This can be used to optimize some platforms while adding, removing, or changing many child controls at once. It disables the calculation of control positioning until ResumeLayout() is called. Each call to SuspendLayout() must be balanced with a call to ResumeLayout().
SuspendLayout

UnhandleEvent

public void UnhandleEvent(string id)
Called when the last subscriber to an event has been removed, giving WidgetHandler<TWidget>.DetachEvent(string) the chance to stop listening for it.
inherited fromWidgetHandler<TWidget>

UpdateLayout

#
public void UpdateLayout()
Updates the layout of this control if necessary.
Remarks: This will ensure the control has had all of its layout applied so you can use its position and size right after this call. Most platforms (except WinForms) use a deferred layout system so that after adding your control to the form dynamically it won't get laid out until the next idle loop. This is useful when you need to know the dimensions of the control immediately.
UpdateLayout