unreal.Widget

class unreal.Widget(outer=None, name='None')

Bases: unreal.Visual

This is the base class for all wrapped Slate controls that are exposed to UObjects.

C++ Source:

  • Module: UMG

  • File: Widget.h

Editor Properties: (see get_editor_property/set_editor_property)

  • accessible_behavior (SlateAccessibleBehavior): [Read-Write] Whether or not the widget is accessible, and how to describe it. If set to custom, additional customization options will appear.

  • accessible_summary_behavior (SlateAccessibleBehavior): [Read-Write] How to describe this widget when it’s being presented through a summary of a parent widget. If set to custom, additional customization options will appear.

  • accessible_summary_text (Text): [Read-Write] When AccessibleSummaryBehavior is set to Custom, this is the text that will be used to describe the widget.

  • accessible_text (Text): [Read-Write] When AccessibleBehavior is set to Custom, this is the text that will be used to describe the widget.

  • can_children_be_accessible (bool): [Read-Write] Whether or not children of this widget can appear as distinct accessible widgets.

  • clipping (WidgetClipping): [Read-Write] Controls how the clipping behavior of this widget. Normally content that overflows the bounds of the widget continues rendering. Enabling clipping prevents that overflowing content from being seen.

    NOTE: Elements in different clipping spaces can not be batched together, and so there is a performance cost to clipping. Do not enable clipping unless a panel actually needs to prevent content from showing up outside its bounds.

  • cursor (MouseCursor): [Read-Write] The cursor to show when the mouse is over the widget

  • flow_direction_preference (FlowDirectionPreference): [Read-Write] Allows you to set a new flow direction

  • is_enabled (bool): [Read-Write] Sets whether this widget can be modified interactively by the user

  • is_volatile (bool): [Read-Write] If true prevents the widget or its child’s geometry or layout information from being cached. If this widget changes every frame, but you want it to still be in an invalidation panel you should make it as volatile instead of invalidating it every frame, which would prevent the invalidation panel from actually ever caching anything.

  • navigation (WidgetNavigation): [Read-Write] The navigation object for this widget is optionally created if the user has configured custom navigation rules for this widget in the widget designer. Those rules determine how navigation transitions can occur between widgets.

  • override_accessible_defaults (bool): [Read-Write] Override all of the default accessibility behavior and text for this widget.

  • override_cursor (bool): [Read-Write] Override Cursor

  • render_opacity (float): [Read-Write] The opacity of the widget

  • render_transform (WidgetTransform): [Read-Write] The render transform of the widget allows for arbitrary 2D transforms to be applied to the widget.

  • render_transform_pivot (Vector2D): [Read-Write] The render transform pivot controls the location about which transforms are applied. This value is a normalized coordinate about which things like rotations will occur.

  • slot (PanelSlot): [Read-Write] The parent slot of the UWidget. Allows us to easily inline edit the layout controlling this widget.

  • tool_tip_text (Text): [Read-Write] Tooltip text to show when the user hovers over the widget with the mouse

  • tool_tip_widget (Widget): [Read-Only] Tooltip widget to show when the user hovers over the widget with the mouse

  • visibility (SlateVisibility): [Read-Write] The visibility of the widget

property cursor

[Read-Only] The cursor to show when the mouse is over the widget

Type

(MouseCursor)

force_layout_prepass()None

Forces a pre-pass. A pre-pass caches the desired size of the widget hierarchy owned by this widget. One pre-pass already happens for every widget before Tick occurs. You only need to perform another pre-pass if you are adding child widgets this frame and want them to immediately be visible this frame.

force_volatile(force)None

Sets the forced volatility of the widget.

Parameters

force (bool) –

get_accessible_summary_text()Text

Gets the accessible summary text from the underlying Slate accessible widget.

Returns

The accessible summary text of the underlying Slate accessible widget. Returns an empty text if accessibility is dsabled or the underlying accessible widget is invalid.

Return type

Text

get_accessible_text()Text

Gets the accessible text from the underlying Slate accessible widget

Returns

The accessible text of the underlying Slate accessible widget. Returns an empty text if accessibility is dsabled or the underlying accessible widget is invalid.

Return type

Text

get_cached_geometry()Geometry

Gets the last geometry used to Tick the widget. This data may not exist yet if this call happens prior to the widget having been ticked/painted, or it may be out of date, or a frame behind.

We recommend not to use this data unless there’s no other way to solve your problem. Normally in Slate we try and handle these issues by making a dependent widget part of the hierarchy, as to avoid frame behind or what are referred to as hysteresis problems, both caused by depending on geometry from the previous frame being used to advise how to layout a dependent object the current frame.

Returns

Return type

Geometry

get_clipping()WidgetClipping

Gets the clipping state of this widget.

Returns

Return type

WidgetClipping

get_desired_size()Vector2D

Gets the widgets desired size. NOTE: The underlying Slate widget must exist and be valid, also at least one pre-pass must

have occurred before this value will be of any use.

Returns

The widget’s desired size

Return type

Vector2D

get_game_instance()GameInstance

Gets the game instance associated with this UI.

Returns

a pointer to the owning game instance

Return type

GameInstance

get_is_enabled()bool

Gets the current enabled status of the widget

Returns

Return type

bool

get_opacity()

deprecated: ‘get_opacity’ was renamed to ‘get_render_opacity’.

get_owning_local_player()LocalPlayer

Gets the local player associated with this UI.

Returns

The owning local player.

Return type

LocalPlayer

get_owning_player()PlayerController

Gets the player controller associated with this UI.

Returns

The player controller that owns the UI.

Return type

PlayerController

get_paint_space_geometry()Geometry

Get Paint Space Geometry

Returns

Return type

Geometry

get_parent()PanelWidget

Gets the parent widget

Returns

Return type

PanelWidget

get_render_opacity()float

Gets the current visibility of the widget.

Returns

Return type

float

get_render_transform_angle()float

Get Render Transform Angle

Returns

Return type

float

get_tick_space_geometry()Geometry

Get Tick Space Geometry

Returns

Return type

Geometry

get_visibility()SlateVisibility

Gets the current visibility of the widget.

Returns

Return type

SlateVisibility

has_any_user_focus()bool

Returns true if this widget is focused by any user.

Returns

Return type

bool

has_focused_descendants()bool

Returns true if any descendant widget is focused by any user.

Returns

Return type

bool

has_keyboard_focus()bool

Checks to see if this widget currently has the keyboard focus

Returns

True if this widget has keyboard focus

Return type

bool

has_mouse_capture()bool

Checks to see if this widget is the current mouse captor

Returns

True if this widget has captured the mouse

Return type

bool

has_mouse_capture_by_user(user_index, pointer_index=- 1)bool

Checks to see if this widget is the current mouse captor

Parameters
  • user_index (int32) –

  • pointer_index (int32) –

Returns

True if this widget has captured the mouse with given user and pointer

Return type

bool

has_user_focus(player_controller)bool

Returns true if this widget is focused by a specific user.

Parameters

player_controller (PlayerController) –

Returns

Return type

bool

has_user_focused_descendants(player_controller)bool

Returns true if any descendant widget is focused by a specific user.

Parameters

player_controller (PlayerController) –

Returns

Return type

bool

invalidate_layout_and_volatility()None

Invalidates the widget from the view of a layout caching widget that may own this widget. will force the owning widget to redraw and cache children on the next paint pass.

property is_enabled

[Read-Only] Sets whether this widget can be modified interactively by the user

Type

(bool)

is_hovered()bool

Returns true if the widget is currently being hovered by a pointer device

Returns

Return type

bool

is_visible()bool

Returns true if the widget is Visible, HitTestInvisible or SelfHitTestInvisible.

Returns

Return type

bool

property is_volatile

[Read-Only] If true prevents the widget or its child’s geometry or layout information from being cached. If this widget changes every frame, but you want it to still be in an invalidation panel you should make it as volatile instead of invalidating it every frame, which would prevent the invalidation panel from actually ever caching anything.

Type

(bool)

property navigation

[Read-Only] The navigation object for this widget is optionally created if the user has configured custom navigation rules for this widget in the widget designer. Those rules determine how navigation transitions can occur between widgets.

Type

(WidgetNavigation)

remove_from_parent()None

Removes the widget from its parent widget. If this widget was added to the player’s screen or the viewport it will also be removed from those containers.

property render_transform

[Read-Only] The render transform of the widget allows for arbitrary 2D transforms to be applied to the widget.

Type

(WidgetTransform)

property render_transform_pivot

[Read-Only] The render transform pivot controls the location about which transforms are applied. This value is a normalized coordinate about which things like rotations will occur.

Type

(Vector2D)

reset_cursor()None

Resets the cursor to use on the widget, removing any customization for it.

set_all_navigation_rules(rule, widget_to_focus)None

Sets the widget navigation rules for all directions. This can only be called on widgets that are in a widget tree.

Parameters
  • rule (UINavigationRule) – The rule to use when navigation is taking place

  • widget_to_focus (Name) – When using the Explicit rule, focus on this widget

set_clipping(clipping)None

Sets the clipping state of this widget.

Parameters

clipping (WidgetClipping) –

set_cursor(cursor)None

Sets the cursor to show over the widget.

Parameters

cursor (MouseCursor) –

set_focus()None

Sets the focus to this widget for the owning user

set_is_enabled(is_enabled)None

Sets the current enabled status of the widget

Parameters

is_enabled (bool) –

set_keyboard_focus()None

Sets the focus to this widget.

set_navigation_rule(direction, rule, widget_to_focus)None

Set Navigation Rule

Parameters
set_navigation_rule_base(direction, rule)None

Sets the widget navigation rules for a specific direction. This can only be called on widgets that are in a widget tree. This works only for non Explicit, non Custom and non CustomBoundary Rules.

Parameters
set_navigation_rule_custom(direction, custom_delegate)None

Sets the widget navigation rules for a specific direction. This can only be called on widgets that are in a widget tree. This works only for Custom Rule.

Parameters
set_navigation_rule_custom_boundary(direction, custom_delegate)None

Sets the widget navigation rules for a specific direction. This can only be called on widgets that are in a widget tree. This works only for CustomBoundary Rule.

Parameters
set_navigation_rule_explicit(direction, widget)None

Sets the widget navigation rules for a specific direction. This can only be called on widgets that are in a widget tree. This works only for Explicit Rule.

Parameters
set_opacity(opacity)

deprecated: ‘set_opacity’ was renamed to ‘set_render_opacity’.

set_render_angle(angle)

deprecated: ‘set_render_angle’ was renamed to ‘set_render_transform_angle’.

set_render_opacity(opacity)None

Sets the visibility of the widget.

Parameters

opacity (float) –

set_render_scale(scale)None

Set Render Scale

Parameters

scale (Vector2D) –

set_render_shear(shear)None

Set Render Shear

Parameters

shear (Vector2D) –

set_render_transform(transform)None

Set Render Transform

Parameters

transform (WidgetTransform) –

set_render_transform_angle(angle)None

Set Render Transform Angle

Parameters

angle (float) –

set_render_transform_pivot(pivot)None

Set Render Transform Pivot

Parameters

pivot (Vector2D) –

set_render_translation(translation)None

Set Render Translation

Parameters

translation (Vector2D) –

set_tool_tip(widget)None

Sets a custom widget as the tooltip of the widget.

Parameters

widget (Widget) –

set_tool_tip_text(tool_tip_text)None

Sets the tooltip text for the widget.

Parameters

tool_tip_text (Text) –

set_user_focus(player_controller)None

Sets the focus to this widget for a specific user (if setting focus for the owning user, prefer SetFocus())

Parameters

player_controller (PlayerController) –

set_visibility(visibility)None

Sets the visibility of the widget.

Parameters

visibility (SlateVisibility) –

property slot

[Read-Only] The parent slot of the UWidget. Allows us to easily inline edit the layout controlling this widget.

Type

(PanelSlot)

property tool_tip_text

[Read-Only] Tooltip text to show when the user hovers over the widget with the mouse

Type

(Text)

property tool_tip_widget

[Read-Only] Tooltip widget to show when the user hovers over the widget with the mouse

Type

(Widget)