s&box docs

public class Editor.Widget : Editor.QObject

A generic widget.

Broader workflow and conceptual references connected to this API.

Constructors

Showing 2 constructors

Methods

Showing 76 methods

public void AdjustSize()

Adjusts the size of the widget to fit its contents.

public virtual void AlignToParent(Sandbox.TextFlag alignment, Vector2 offset = null)

Align this widget to its parents edge, with an offset.

Parameters

  • offset: Default: null

public void Blur()

Clear keyboard focus from this widget.

public virtual void ChildValuesChanged(Editor.Widget source)

public void ClearContext(string key)

Remove a context on this widget. This will NOT remove contexts set from parent objects.

public virtual void Close()

If a window - will close

public void ConstrainTo(Sandbox.Rect parentRect)

Reposition this widget to ensure it is within the given rectangle.

Parameters

  • parentRect: Rectangle to constraint to, relative to the parent widget.

public void ConstrainToScreen()

Constrain this widget to the screen it's currently on.

public void DestroyChildren()

Destroys all child widgets of this widget.

public void DisableWindowActivation()

Calling this will set the WS_EX_NOACTIVATE flag on the window internally, which will stop it taking focus away from other windows.

protected virtual void DoLayout()

Called to make sure all child panels are in correct positions and have correct sizes. This is typically called when the size of this widget changes, but there are other cases as well.

public void Focus(bool activateWindow = True)

Parameters

  • activateWindow: Default: True

protected virtual bool FocusNext()

Called when Tab is pressed to find the next widget to focus. Return true to prevent focusing.

protected virtual bool FocusPrevious()

Called when Shift + Tab is pressed to find the next widget to focus. Return true to prevent focusing.

public Vector2 FromScreen(Vector2 p)

Transform coordinates relative to the monitors's top left corner, to coordinates relative to panel's top left corner.

Parameters

  • p: Position relative to the monitors top left corner.

Returns

The same position on the panel, relative it its top left corner.

public T GetAncestor()

Find the closest ancestor widget of type

public T GetContext(string key, T defaultIfMissing = null)

Find a context on this widget. If not found, look at the parent. If not found, look at the parent. This is useful for passing information down to child widgets without any effort.

Parameters

  • defaultIfMissing: Default: null

public System.Collections.Generic.IEnumerable`1<T> GetDescendants()

Get all descendants of type T

public Editor.Widget GetWindow()

Get the top level window widget

public virtual void Hide()

Make this widget not visible.

public bool IsAncestorOf(Editor.Widget child)

Returns whether or not the specified Widget is an ancestor of this Widget.

public bool IsDescendantOf(Editor.Widget parent)

Returns whether or not the specified Widget is a descendent of this Widget.

public bool IsModal()

Returns true if this is a modal window. This means it will appear on top of everything and block input to everything else.

public void Lower()

Lowers the widget to the bottom of the parent widget's stack. After this call the widget will be visually behind (and therefore obscured by) any overlapping sibling widgets.

public void MakeMaximized()

public void MakeMinimized()

public void MakeSignal(string name)

public void MakeWindowed()

protected virtual Vector2 MinimumSizeHint()

Return the minimum size this widget wants to be

protected virtual void OnBlur(Editor.FocusChangeReason reason)

Called when the widget loses keyboard focus.

protected virtual bool OnClose()

Called when a window is about to be closed.

protected virtual void OnClosed()

Called when a window is closed.

protected virtual void OnContextMenu(Editor.ContextMenuEvent e)

Called after `Editor.Widget.OnMouseRightClick(Editor.MouseEvent)`, for the purposes of opening a context menu.

protected virtual void OnDoubleClick(Editor.MouseEvent e)

Called when the widget was double clicked with any mouse button.

public virtual void OnDragDrop(Editor.Widget.DragEvent ev)

Something was dragged and dropped on this widget. Apply the data here, if its valid. Requires `Editor.Widget.AcceptDrops` to function.

Parameters

  • ev: The drag event info.

public virtual void OnDragHover(Editor.Widget.DragEvent ev)

Cursor with drag and drop data moved on this widget. Requires `Editor.Widget.AcceptDrops` to function.

Parameters

  • ev: The drag event info.

public virtual void OnDragLeave()

Cursor with drag and drop data left the bounds of this widget. Requires `Editor.Widget.AcceptDrops` to function.

protected virtual void OnDragStart()

Called when dragging. `Editor.Widget.IsDraggable` should be true.

protected virtual void OnFocus(Editor.FocusChangeReason reason)

Called when the widget gains keyboard focus.

protected virtual void OnKeyPress(Editor.KeyEvent e)

A key has been pressed. Your widget needs keyboard focus for this to be called - see FocusMode.

protected virtual void OnKeyRelease(Editor.KeyEvent e)

A key has been released.

protected virtual void OnMouseClick(Editor.MouseEvent e)

Called when this widget is left clicked (on mouse release).

protected virtual void OnMouseEnter()

Mouse cursor entered the bounds of this widget.

protected virtual void OnMouseLeave()

Mouse cursor exited the bounds of this widget.

protected virtual void OnMouseMove(Editor.MouseEvent e)

Called when the mouse cursor is moved while being over this widget.

protected virtual void OnMousePress(Editor.MouseEvent e)

Called when mouse is pressed over this widget.

protected virtual void OnMouseReleased(Editor.MouseEvent e)

Called when mouse is released over this widget.

protected virtual void OnMouseRightClick(Editor.MouseEvent e)

Called when this widget is right clicked (on mouse release).

protected virtual void OnMouseWheel(Editor.WheelEvent e)

Mouse wheel was scrolled while the mouse cursor was over this widget.

protected virtual void OnMoved()

Called when the widget was moved to a new position relative to it's parent.

protected virtual void OnPaint()

Override to custom paint your widget, for example using `Editor.Paint`. Can be overwritten by `Editor.Widget.OnPaintOverride`.

Implementations

protected virtual void OnResize()

Called when the widgets' size was changed.

protected virtual void OnShortcutPressed(Editor.KeyEvent e)

A shortcut has been activated. This is called on the focused control so they can override it.

protected virtual void OnVisibilityChanged(bool visible)

Called when the visibility of this widget changes.

protected virtual void OnWheel(Editor.WheelEvent e)Obsolete

Mouse wheel was scrolled while the mouse cursor was over this widget.

Obsolete: Use OnMouseWheel

public void PostKeyEvent(Editor.KeyCode key)

public void Raise()

Raises this widget to the top of the parent widget's stack. After this call the widget will be visually in front of any overlapping sibling widgets.

public void RestoreGeometry(string state)

Restore position and size previously stored via `Editor.Widget.SaveGeometry`.

public string SaveGeometry()

Serialize position and size of this widget to a string, which can then be passed to `Editor.Widget.RestoreGeometry(System.String)`.

public void SetContext(string key, object value)

Set a context value on this widget. This context will be available to its children via FindContext.

public void SetEffectOpacity(float f)

public void SetModal(bool on, bool application = False)

Set this window to be modal. This means it will appear on top of everything and block input to everything else.

Parameters

  • application: Default: False

public void SetStyles(string sheet)

Directly set CSS style sheet(s) for this widget. Same format as a .css file.

public void SetStylesheetFile(string filename)

Set a file to load CSS for this widget from.

public virtual void Show()

Make this widget visible.

protected void SignalValuesChanged()

When a value on this widget changed due to user input (ie, checking a box, editing a form) this is called, which sends a signal up the parent widgets.

protected virtual Vector2 SizeHint()

Should return the size this widget really wants to be if it can its way. The default is that you don't care - and just to return whatever the base value is.

public Vector2 ToScreen(Vector2 p)

Transform coordinates relative to the panel's top left corner, to coordinates relative to monitors's top left corner.

Parameters

  • p: Position on the panel, relative it its top left corner.

Returns

The same position relative to the monitors top left corner.

public virtual void Update()

Tell this widget that shit changed and it needs to redraw

public void UpdateGeometry()

Tell everything that the geometry of this has changed

Properties

Showing 63 properties

public bool Editor.Widget.AcceptDrops { get; set; }

Accept drag and dropping shit on us

public System.Collections.Generic.IEnumerable`1<Editor.Widget> Editor.Widget.Children { get; set; }

Child widgets of this widget.

public Sandbox.Rect Editor.Widget.ContentRect { get; set; }

public bool Editor.Widget.ContextMenuEnabled { get; set; }

Enables or disables the context menu on this widget.

public bool Editor.Widget.DebugModeEnabled { get; set; }

Enable debug mode on this widget.

public bool Editor.Widget.DeleteOnClose { get; set; }

Delete this widget when close is pressed

public float Editor.Widget.DpiScale { get; set; }

The scale this widget is using (multiplying Size by this value gives the actual native size)

public bool Editor.Widget.Enabled { get; set; }

Makes the widget not interactable. This is also usually be reflected visually by the widget. The widget will not process any keyboard or mouse inputs. Applies retroactively to all children.

public float Editor.Widget.FixedHeight { get; set; }

Sets the fixed height for this widget

public float Editor.Widget.FixedWidth { get; set; }

Sets the fixed width for this widget

public Editor.FocusMode Editor.Widget.FocusMode { get; set; }

Sets the focus mode for this widget. This determines both how it will get focus and whether it will receive keyboard input.

public bool Editor.Widget.HasMaximizeButton { get; set; }

public float Editor.Widget.Height { get; set; }

Utility to interact with a widget's width - use Size where possible

public bool Editor.Widget.Hidden { get; set; }

Whether this widget is hidden. This differs from Visible because this will return the state for this particular widget, where as Visible returns false if a parent is hidden etc.

public bool Editor.Widget.IsActiveWindow { get; set; }

public bool Editor.Widget.IsBeingDroppedOn { get; set; }

Whether something is being dragged over this widget.

public bool Editor.Widget.IsDraggable { get; set; }

Whether this widget can be drag and dropped onto other widgets.

public bool Editor.Widget.IsFocused { get; set; }

Whether this widget has keyboard focus.

public bool Editor.Widget.IsFramelessWindow { get; set; }

public bool Editor.Widget.IsMaximized { get; set; }

public bool Editor.Widget.IsMinimized { get; set; }

public bool Editor.Widget.IsPopup { get; set; }

public bool Editor.Widget.IsPressed { get; set; }

Whether this widget is currently being pressed down or not.

public bool Editor.Widget.IsTooltip { get; set; }

public bool Editor.Widget.IsUnderMouse { get; set; }

public bool Editor.Widget.IsWindow { get; set; }

public Editor.Layout Editor.Widget.Layout { get; set; }

The widget's internal layout, if any

public Sandbox.Rect Editor.Widget.LocalRect { get; set; }

This panel's rect at 0,0

public float Editor.Widget.MaximumHeight { get; set; }

This widgets height should never be larger than the given value.

public Vector2 Editor.Widget.MaximumSize { get; set; }

Sets `Editor.Widget.MaximumWidth` and `Editor.Widget.MaximumHeight` simultaneously.

public float Editor.Widget.MaximumWidth { get; set; }

This widgets width should never be larger than the given value.

public float Editor.Widget.MinimumHeight { get; set; }

This widgets height should never be smaller than the given value.

public Vector2 Editor.Widget.MinimumSize { get; set; }

Sets `Editor.Widget.MinimumWidth` and `Editor.Widget.MinimumHeight` simultaneously.

public float Editor.Widget.MinimumWidth { get; set; }

This widgets width should never be smaller than the given value.

public bool Editor.Widget.MouseTracking { get; set; }

public string Editor.Widget.Name { get; set; }

Name of the widget, usually for debugging purposes.

public bool Editor.Widget.NoSystemBackground { get; set; }

public Editor.Widget Editor.Widget.Parent { get; set; }

Parent widget. If non null, position of this widget will be relative to the parent widget. Certain events will also propagate to the parent widget if unhandled.

public virtual Editor.Pixmap Editor.Widget.PixmapCursor { get; set; }

Custom cursor override for this widget. Will override `Editor.Widget.Cursor` with `Editor.CursorShape.CustomCursor`.

public Vector2 Editor.Widget.Position { get; set; }

Position of this widget, relative to its parent if it has one.

public virtual bool Editor.Widget.ProvidesDebugMode { get; set; }

If true then this widget has a debug mode that can be activated

public virtual bool Editor.Widget.ReadOnly { get; set; }

Makes the widget read only. I.e. You can copy text of a text entry, but can't edit it. Applies retroactively to all children.

public Sandbox.Rect Editor.Widget.ScreenGeometry { get; set; }

Returns the geometry of the screen this widget is currently on.

public Vector2 Editor.Widget.ScreenPosition { get; set; }

Position of the widget relative to the monitor's top left corner.

public Sandbox.Rect Editor.Widget.ScreenRect { get; set; }

This panel's rect in screen coordinates

public bool Editor.Widget.ShowWithoutActivating { get; set; }

public Vector2 Editor.Widget.Size { get; set; }

Size of this widget.

public string Editor.Widget.StatusTip { get; set; }

If set, hovering over this widget will set the text of a `Editor.StatusBar` of the window the widget belongs to.

public virtual string Editor.Widget.ToolTip { get; set; }

If set, this text will be displayed after a certain delay of hovering this widget with the mouse cursor.

public bool Editor.Widget.TranslucentBackground { get; set; }

public bool Editor.Widget.TransparentForMouseEvents { get; set; }

public bool Editor.Widget.UpdatesEnabled { get; set; }

If true, Update will call

public bool Editor.Widget.Visible { get; set; }

Whether this widget is visible or not, in the tree. This will return false if a parent is hidden. You might want to set Hidden if you're looking to check local visible status on a widget.

public float Editor.Widget.Width { get; set; }

Utility to interact with a widget's width - use Size where possible

public float Editor.Widget.WindowOpacity { get; set; }

public virtual string Editor.Widget.WindowTitle { get; set; }

Metadata

FieldValue
NamespaceEditor
Typeclass
AssemblySandbox.Tools
Doc IDT:Editor.Widget

On this page

Constructorspublic Widget()public Widget(Editor.Widget parent, System.Boolean isDarkWindow = False)Methodspublic System.Void AdjustSize()public virtual System.Void AlignToParent(Sandbox.TextFlag alignment, Vector2 offset = null)public System.Void Blur()public virtual System.Void ChildValuesChanged(Editor.Widget source)public System.Void ClearContext(System.String key)public virtual System.Void Close()public System.Void ConstrainTo(Sandbox.Rect parentRect)public System.Void ConstrainToScreen()public System.Void DestroyChildren()public System.Void DisableWindowActivation()protected virtual System.Void DoLayout()public System.Void Focus(System.Boolean activateWindow = True)protected virtual System.Boolean FocusNext()protected virtual System.Boolean FocusPrevious()public Vector2 FromScreen(Vector2 p)public T GetAncestor()public T GetContext(System.String key, T defaultIfMissing = null)public System.Collections.Generic.IEnumerable`1<T> GetDescendants()public Editor.Widget GetWindow()public virtual System.Void Hide()public System.Boolean IsAncestorOf(Editor.Widget child)public System.Boolean IsDescendantOf(Editor.Widget parent)public System.Boolean IsModal()public System.Void Lower()public System.Void MakeMaximized()public System.Void MakeMinimized()public System.Void MakeSignal(System.String name)public System.Void MakeWindowed()protected virtual Vector2 MinimumSizeHint()protected virtual System.Void OnBlur(Editor.FocusChangeReason reason)protected virtual System.Boolean OnClose()protected virtual System.Void OnClosed()protected virtual System.Void OnContextMenu(Editor.ContextMenuEvent e)protected virtual System.Void OnDoubleClick(Editor.MouseEvent e)public virtual System.Void OnDragDrop(Editor.Widget.DragEvent ev)public virtual System.Void OnDragHover(Editor.Widget.DragEvent ev)public virtual System.Void OnDragLeave()protected virtual System.Void OnDragStart()protected virtual System.Void OnFocus(Editor.FocusChangeReason reason)protected virtual System.Void OnKeyPress(Editor.KeyEvent e)protected virtual System.Void OnKeyRelease(Editor.KeyEvent e)protected virtual System.Void OnMouseClick(Editor.MouseEvent e)protected virtual System.Void OnMouseEnter()protected virtual System.Void OnMouseLeave()protected virtual System.Void OnMouseMove(Editor.MouseEvent e)protected virtual System.Void OnMousePress(Editor.MouseEvent e)protected virtual System.Void OnMouseReleased(Editor.MouseEvent e)protected virtual System.Void OnMouseRightClick(Editor.MouseEvent e)protected virtual System.Void OnMouseWheel(Editor.WheelEvent e)protected virtual System.Void OnMoved()protected virtual System.Void OnPaint()protected virtual System.Void OnResize()protected virtual System.Void OnShortcutPressed(Editor.KeyEvent e)protected virtual System.Void OnVisibilityChanged(System.Boolean visible)protected virtual System.Void OnWheel(Editor.WheelEvent e)public System.Void PostKeyEvent(Editor.KeyCode key)public System.Void Raise()public System.Void RestoreGeometry(System.String state)public System.String SaveGeometry()public System.Boolean SetContentHash(System.Func`1<System.Int32> getHash, System.Single secondsDebounce = 0.1)public System.Boolean SetContentHash(System.Int32 hash, System.Single secondsDebounce = 0.1)public System.Void SetContext(System.String key, System.Object value)public System.Void SetEffectOpacity(System.Single f)public System.Void SetModal(System.Boolean on, System.Boolean application = False)public System.Void SetSizeMode(Editor.SizeMode horizontal, Editor.SizeMode vertical)public System.Void SetStyles(System.String sheet)public System.Void SetStylesheetFile(System.String filename)public virtual System.Void SetWindowIcon(Editor.Pixmap icon)public virtual System.Void SetWindowIcon(System.String name)public virtual System.Void Show()protected virtual System.Void Signal(Editor.WidgetSignal signal)protected System.Void SignalValuesChanged()protected virtual Vector2 SizeHint()public Vector2 ToScreen(Vector2 p)public virtual System.Void Update()public System.Void UpdateGeometry()Propertiespublic System.Boolean Editor.Widget.AcceptDrops { get; set; }public System.Collections.Generic.IEnumerable`1<Editor.Widget> Editor.Widget.Children { get; set; }public Sandbox.UI.Margin Editor.Widget.ContentMargins { get; set; }public Sandbox.Rect Editor.Widget.ContentRect { get; set; }public System.Boolean Editor.Widget.ContextMenuEnabled { get; set; }public virtual Editor.CursorShape Editor.Widget.Cursor { get; set; }public System.Boolean Editor.Widget.DebugModeEnabled { get; set; }public System.Boolean Editor.Widget.DeleteOnClose { get; set; }public System.Single Editor.Widget.DpiScale { get; set; }public System.Boolean Editor.Widget.Enabled { get; set; }public System.Single Editor.Widget.FixedHeight { get; set; }public Vector2 Editor.Widget.FixedSize { get; set; }public System.Single Editor.Widget.FixedWidth { get; set; }public Editor.FocusMode Editor.Widget.FocusMode { get; set; }public Editor.Widget Editor.Widget.FocusProxy { get; set; }public System.Boolean Editor.Widget.HasMaximizeButton { get; set; }public System.Single Editor.Widget.Height { get; set; }public System.Boolean Editor.Widget.Hidden { get; set; }public Editor.SizeMode Editor.Widget.HorizontalSizeMode { get; set; }public System.Boolean Editor.Widget.IsActiveWindow { get; set; }public System.Boolean Editor.Widget.IsBeingDroppedOn { get; set; }public System.Boolean Editor.Widget.IsDraggable { get; set; }public System.Boolean Editor.Widget.IsFocused { get; set; }public System.Boolean Editor.Widget.IsFramelessWindow { get; set; }public System.Boolean Editor.Widget.IsMaximized { get; set; }public System.Boolean Editor.Widget.IsMinimized { get; set; }public System.Boolean Editor.Widget.IsPopup { get; set; }public System.Boolean Editor.Widget.IsPressed { get; set; }public System.Boolean Editor.Widget.IsTooltip { get; set; }public System.Boolean Editor.Widget.IsUnderMouse { get; set; }public System.Boolean Editor.Widget.IsWindow { get; set; }public Editor.Layout Editor.Widget.Layout { get; set; }public Sandbox.Rect Editor.Widget.LocalRect { get; set; }public System.Single Editor.Widget.MaximumHeight { get; set; }public Vector2 Editor.Widget.MaximumSize { get; set; }public System.Single Editor.Widget.MaximumWidth { get; set; }public System.Single Editor.Widget.MinimumHeight { get; set; }public Vector2 Editor.Widget.MinimumSize { get; set; }public System.Single Editor.Widget.MinimumWidth { get; set; }public System.Boolean Editor.Widget.MouseTracking { get; set; }public System.String Editor.Widget.Name { get; set; }public System.Boolean Editor.Widget.NoSystemBackground { get; set; }public Editor.Widget Editor.Widget.Parent { get; set; }public virtual Editor.Pixmap Editor.Widget.PixmapCursor { get; set; }public Vector2 Editor.Widget.Position { get; set; }public virtual System.Boolean Editor.Widget.ProvidesDebugMode { get; set; }public virtual System.Boolean Editor.Widget.ReadOnly { get; set; }public Sandbox.Rect Editor.Widget.ScreenGeometry { get; set; }public Vector2 Editor.Widget.ScreenPosition { get; set; }public Sandbox.Rect Editor.Widget.ScreenRect { get; set; }public System.Boolean Editor.Widget.ShowWithoutActivating { get; set; }public Vector2 Editor.Widget.Size { get; set; }public System.String Editor.Widget.StatusTip { get; set; }public virtual System.String Editor.Widget.ToolTip { get; set; }public System.Boolean Editor.Widget.TranslucentBackground { get; set; }public System.Boolean Editor.Widget.TransparentForMouseEvents { get; set; }public System.Boolean Editor.Widget.UpdatesEnabled { get; set; }public Editor.SizeMode Editor.Widget.VerticalSizeMode { get; set; }public System.Boolean Editor.Widget.Visible { get; set; }public System.Single Editor.Widget.Width { get; set; }public Editor.WindowFlags Editor.Widget.WindowFlags { get; set; }public System.Single Editor.Widget.WindowOpacity { get; set; }public virtual System.String Editor.Widget.WindowTitle { get; set; }Metadata