Window.IHandler
ReferencesHandler interface for the Window
Properties
AllowDrop
Gets or sets a value indicating whether this control can serve as drop target.
AutoSize
#Gets or sets a value indicating that the window will automatically resize when its content changes
Remarks: Note that if you set both dimensions of the Size and/or Container.ClientSize, this will be set to false.
Value:
true to auto size the window when its content changes, false to only auto size when first createdBackgroundColor
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.
Value: The color of the background.
Gets or sets the size and location of the window
Remarks: Where the platform provides an API to set both the size and location at once, handlers should use it so the window is repositioned and resized in a single operation instead of two separate steps.
Value: The bounding rectangle of the window
Closeable
#Gets or sets a value indicating whether the close button should be shown. Defaults to
trueRemarks: Note that on some platforms (e.g. Windows) this also hides the system menu if Minimizable and Maximizable are also false. Note that this does not prevent the window from being closed, to do that use the Window.Closing event.
Value:
true to show the close button (and in some platforms the system menu), false to hide them.Remarks: The main content will be offset by the Panel.IHandler.Padding value specified, and will take up the entire content area of the control. Some controls may have decorations that will surround the content, such as a GroupBox, TabControl, or Window
Value: The child content of the control.
Cursor
Gets or sets the type of cursor to use when the mouse is hovering over the control
inherited fromControl.IHandler
Remarks: Typically when a control is disabled, the user cannot do anything with the control (including for example, selecting text in a text control). Certain controls can have a 'Read Only' mode, such as TextBox.ReadOnly which allows the user to select text, but not change its contents.
Value:
true if enabled; otherwise, false.HasFocus
Gets a value indicating whether this instance has the keyboard input focus.
Value:
true if this instance has focus; otherwise, false.Icon
#Gets or sets the icon for the window to show in the menu bar.
Remarks: The icon should have many variations, such as 16x16, 24x24, 32x32, 48x48, 64x64, etc. This ensures that the many places it is used (title bar, task bar, switch window, etc) all have optimized icon sizes. For OS X, the application icon is specified in the .app bundle, not by this value.
Value: The icon for this window.
Remarks: Some platforms may use this to identify controls (e.g. web)
IsMouseCaptured
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().
Location
#Gets or sets the location of the window
Remarks: Note that in multi-monitor setups, the origin of the location is at the upper-left of Screen.PrimaryScreen. Also note, that on Linux systems running GTK via Wayland, the location is relative to the Window.Owner when one is set and the WindowStyle is WindowStyle.None; otherwise it will always point to
0, 0 and setting it to different values will have no effect. Using Control.PointToScreen(PointF) on a control within the Window.Owner can be used to position the window relative to specific elements of the owner.LogicalPixelSize
#Gets the number of pixels per logical pixel when on a high DPI display.
Remarks: This indicates the number of pixels per logical pixel. All units in Eto.Forms such as control size, drawing operations, etc are in logical pixels. When not in high DPI, this will be 1.0; Retina displays in OS X will return 2; and in windows this matches the scale set in the monitor settings. Use the Window.LogicalPixelSizeChanged to detect when the window is moved to a display with a different DPI.
Maximizable
#Gets or sets a value indicating whether this Window can be maximized.
Remarks: This may hide or disable the minimize button on the title bar.
Value:
true if maximizable; otherwise, false.Minimizable
#Gets or sets a value indicating whether this Window can be minimized.
Remarks: This may hide or disable the maximize button on the title bar.
Value:
true if minimizable; otherwise, false.MovableByWindowBackground
#Gets or sets a value indicating that the window can be moved by click+dragging the window background
NativeHandle
nint NativeHandle { get; }
Gets the native platform-specific handle for integration purposes
Value: The native handle.
inherited fromPanel.IHandler
Value: The padding around the content.
RecurseToChildren
Gets a value indicating whether PreLoad/Load/LoadComplete/Unload events are propegated to the children controls
Remarks: This is mainly used when you want to use Eto controls in your handler, such as with the ThemedContainerHandler<TContainer, TWidget, TCallback>
Value:
true to recurse events to children; otherwise, false.Resizable
#Gets or sets a value indicating whether this Window is resizable.
Value:
true if resizable; otherwise, false.RestoreBounds
#Gets the bounds of the window before it was minimized or maximized.
Remarks: This is useful to retrieve the desired size and position of the window even though it is currently maximized or minimized.
Value: The restore bounds.
Screen
#Gets the screen this window is mostly contained in. Typically defined by the screen center of the window is visible.
Value: The window's current screen.
ShowInTaskbar
#Gets or sets a value indicating whether this Window will show in the taskbar.
Remarks: Some platforms, e.g. OS X do not show a separate icon for each running window.
Value:
true if the window will show in taskbar; otherwise, false.Size
Gets or sets the size of the control. Use -1 to specify auto sizing for either the width and/or height.
Remarks: Setting the size of controls is entirely optional as most controls will size themselves appropriately. When specifying a size, it will be used as the desired size of the control. The container will reposition and resize the control depending on the available size. For a Window, it is preferred to set the Container.ClientSize instead, as various platforms have different sizes of window decorations, toolbars, etc.
Value: The current size of the control
SupportedPlatformCommands
Gets the supported platform commands that can be used to hook up system functions to user defined logic
Remarks: This lists all available commands that can be mapped using the Control.IHandler.MapPlatformCommand(string, Command) method of the control.
Value: The supported platform commands.
TabIndex
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.
Value: The index of the control in the tab order.
TabStop
Gets or sets a value indicating whether the user can get to this control using the tab key.
Remarks: When
false, the control is skipped when cycling through controls with the tab key, but can still be focused by clicking on it or by calling Control.Focus(). Note that on Gtk this also prevents the control from being focused by clicking on it, and on iOS and Android this has no effect.Value:
true to include the control in the tab order (the default); false to skip it.Title
#Gets or sets the title of the window
Remarks: The title of the window is displayed to the user usually at the top of the window, but in cases where you show a window in a mobile environment, this may be the title shown in a navigation controller.
Value: The title of the window
ToolBar
#Gets or sets the tool bar for the window.
Remarks: Note that each window can only have a single tool bar
Value: The tool bar for the window
ToolTip
Gets or sets the tool tip to show when the mouse is hovered over the control
Topmost
#Gets or sets a value indicating whether this Window is above all other windows.
Remarks: The window should be above all other windows when this is true. In some platforms, this will show above all other windows only when the application has focus.
Value:
true if the window should be topmost; otherwise, false.inherited fromControl.IHandler
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.
Value:
true if visible; otherwise, false.VisualControls
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.
Value: The visual controls.
Methods
Parameters:
| item (Gesture) | Gesture to add. |
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.
Returns:
true if the mouse was captured, false otherwise.ClearGestures
void ClearGestures()
Removes all gestures from the control.
Close
#void Close()
Closes the window
Remarks: Note that once a window is closed, it cannot be shown again in most platforms.
DoDragDrop
Starts drag operation using this control as drag source.
Parameters:
| data (DataObject) | Drag data. |
| allowedEffects (DragEffects) | Allowed effects. |
| image (Image) | Custom drag image |
| cursorOffset (PointF) | Offset of the cursor to the drag image |
Focus
void Focus()
Attempts to set the keyboard input focus to this control, or the first child that accepts focus
GetNativeParentWindow
Gets a parent window wrapper around the native window
GetPreferredSize
Gets the preferred size of this control given the specified
availableSize.Parameters:
| availableSize (SizeF) | The available size to determine the preferred size |
Returns: The preferred size this control would like to be, which can be larger than the specified
availableSize.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.
Initialize
void Initialize()
Called after the widget is constructed
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()
Invalidate
Queues a repaint of the entire control on the screen
Remarks: This is only useful when the control is visible.
Parameters:
| invalidateChildren (bool) | True to invalidate all children, false to only invalidate the container |
Invalidate
Queues a repaint of the specified
rect of the controlMapPlatformCommand
Specifies a command to execute for a platform-specific command
Remarks: Some platforms have specific system-defined commands that can be associated with a control. For example, the Mac platform's cut/copy/paste functionality is defined by the system, and if you want to hook into it, you can use this to map it to your own defined logic. The valid values of the
systemCommand parameter are defined by each platform, and a list can be retrieved using Control.SupportedPlatformCommandsParameters:
| systemCommand (string) | System command. |
| command (Command) | Command to execute, or null to restore to the default behavior |
Example:This example shows how to extend a control with cut/copy/paste for the mac platform:
var drawable = new Drawable();
if (drawable.Generator.IsMac)
{
drawable.MapPlatformCommand("cut", new MyCutCommand());
drawable.MapPlatformCommand("copy", new MyCopyCommand());
drawable.MapPlatformCommand("paste", new MyPasteCommand());
}OnUnLoad
Called when the control is unloaded, which is when it is not currently on a displayed window
PointFromScreen
Converts a point from screen space to control space.
Parameters:
| point (PointF) | Point in screen space |
Returns: The point in control space
Parameters:
| point (PointF) | Point in control space |
Returns: The point in screen space
ReleaseMouseCapture
void ReleaseMouseCapture()
Releases the mouse capture after a call to Control.IHandler.CaptureMouse().
Parameters:
| item (Gesture) | Gesture to remove. |
ResumeLayout
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 Control.IHandler.SuspendLayout() before it.
SetParent
Called when the parent of the control has been set
SuspendLayout
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 Control.IHandler.ResumeLayout() is called. Each call to SuspendLayout() must be balanced with a call to Control.IHandler.ResumeLayout().
UnhandleEvent
Called when the last subscriber to an event has been removed, so the platform can stop listening for it.
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.
Parameters:
| id (string) | ID of the event to stop handling |
UpdateLayout
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.