unreal.Widget

class unreal.Widget(outer: Optional[Object] = None, name: Union[Name, str] = 'None')

Bases: 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] Accessible Behavior: 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] Accessible Summary Behavior: 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] Accessible Summary Text: When AccessibleSummaryBehavior is set to Custom, this is the text that will be used to describe the widget.

  • accessible_text (Text): [Read-Write] Accessible Text: 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] Can Children be Accessible: Whether or not children of this widget can appear as distinct accessible widgets.

  • clipping (WidgetClipping): [Read-Write] Clipping

  • cursor (MouseCursor): [Read-Write] Cursor

  • flow_direction_preference (FlowDirectionPreference): [Read-Write] Flow Direction Preference

  • is_enabled (bool): [Read-Write] Is Enabled

  • is_volatile (bool): [Read-Write] Is Volatile: 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] Navigation: 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 Accessible Defaults: Override all of the default accessibility behavior and text for this widget.

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

  • render_opacity (float): [Read-Write] Render Opacity

  • render_transform (WidgetTransform): [Read-Write] Render Transform

  • render_transform_pivot (Vector2D): [Read-Write] Render Transform Pivot

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

  • tool_tip_text (Text): [Read-Write] Tool Tip Text

  • tool_tip_widget (Widget): [Read-Only] Tool Tip Widget

  • visibility (SlateVisibility): [Read-Write] Visibility

add_field_value_changed_delegate(field_id, delegate) None

K2 Add Field Value Changed Delegate

Parameters:
broadcast_field_value_changed(field_id) None

K2 Broadcast Field Value Changed

Parameters:

field_id (FieldNotificationId) –

property clip_to_bounds: WidgetClipping

‘clip_to_bounds’ was renamed to ‘clipping’.

Type:

deprecated

property clipping: WidgetClipping

[Read-Write] Clipping

Type:

(WidgetClipping)

property cursor: MouseCursor

[Read-Write] Cursor

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.

Return type:

Geometry

get_clipping() WidgetClipping

Gets the clipping state of this widget.

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

Return type:

bool

get_opacity() float

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

Return type:

Geometry

get_parent() PanelWidget

Gets the parent widget

Return type:

PanelWidget

get_render_opacity() float

Gets the current visibility of the widget.

Return type:

float

get_render_transform_angle() float

Get Render Transform Angle

Return type:

float

get_tick_space_geometry() Geometry

Get Tick Space Geometry

Return type:

Geometry

get_visibility() SlateVisibility

Gets the current visibility of the widget.

Return type:

SlateVisibility

has_any_user_focus() bool

Returns true if this widget is focused by any user.

Return type:

bool

has_focused_descendants() bool

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

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) –

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) –

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: bool

[Read-Write] Is Enabled

Type:

(bool)

is_hovered() bool

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

Return type:

bool

is_in_viewport() bool
Returns:

true if the widget was added to the viewport using AddToViewport or AddToPlayerScreen.

Return type:

bool

is_rendered() bool

Returns true if the widget is Visible, HitTestInvisible or SelfHitTestInvisible and the Render Opacity is greater than 0.

Return type:

bool

is_visible() bool

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

Return type:

bool

property is_volatile: bool

[Read-Only] Is Volatile: 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: WidgetNavigation

[Read-Only] Navigation: 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)

property opacity: float

‘opacity’ was renamed to ‘render_opacity’.

Type:

deprecated

remove_field_value_changed_delegate(field_id, delegate) None

K2 Remove Field Value Changed Delegate

Parameters:
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_opacity: float

[Read-Write] Render Opacity

Type:

(float)

property render_transform: WidgetTransform

[Read-Write] Render Transform

Type:

(WidgetTransform)

property render_transform_pivot: Vector2D

[Read-Write] Render Transform Pivot

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 deprecated: Function ‘SetNavigationRule’ is deprecated.

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: float) None

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

set_render_angle(angle: float) None

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: PanelSlot

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

Type:

(PanelSlot)

property tool_tip_text: Text

[Read-Write] Tool Tip Text

Type:

(Text)

property tool_tip_widget: Widget

[Read-Only] Tool Tip Widget

Type:

(Widget)

property visibility: SlateVisibility

[Read-Write] Visibility

Type:

(SlateVisibility)

property visiblity: SlateVisibility

‘visiblity’ was renamed to ‘visibility’.

Type:

deprecated