unreal.CommonButtonBase

class unreal.CommonButtonBase(outer: Object | None = None, name: Name | str = 'None')

Bases: CommonUserWidget

Button that disables itself when not active. Also updates actions for CommonActionWidget if bound to display platform-specific icons.

C++ Source:

  • Plugin: CommonUI

  • Module: CommonUI

  • File: CommonButtonBase.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.

  • apply_alpha_on_disable (bool): [Read-Write] The type of mouse action required by the user to trigger the button’s ‘Click’

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

  • click_event (WidgetEventField): [Read-Write]

  • click_method (ButtonClickMethod): [Read-Write] The type of mouse action required by the user to trigger the button’s ‘Click’

  • 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.

  • color_and_opacity (LinearColor): [Read-Write] The color and opacity of this widget. Tints all child widgets.

  • consume_pointer_input (bool): [Read-Write] Set this to true if you don’t want any pointer (mouse and touch) input to bubble past this widget

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

  • desired_focus_widget (WidgetChild): [Read-Write]

  • display_in_action_bar (bool): [Read-Write] True to generally display this widget’s actions in the action bar, assuming it has actions.

  • display_input_action_when_not_interactable (bool): [Read-Write] True if the input action should be displayed when the button is not interactable

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

  • foreground_color (SlateColor): [Read-Write] The foreground color of the widget, this is inherited by sub widgets. Any color property that is marked as inherit will use this color.

  • hide_input_action (bool): [Read-Write] Whether to hide the input action widget at all times (useful for textless small buttons)

  • hide_input_action_with_keyboard (bool): [Read-Write] True if the input action should be hidden while the user is using a keyboard

  • hold_data (type(Class)): [Read-Write] Press and Hold values used for Keyboard and Mouse, Gamepad and Touch, depending on the current input type

  • hovered_slate_sound_override (SlateSound): [Read-Write] Optional override for the sound to play when this button is hovered. Also used for the Selected and Locked Hovered state if their respective overrides are empty.

  • input_action_widget (CommonActionWidget): [Read-Write] Optionally bound widget for visualization behavior of an input action; NOTE: If specified, will visualize according to the following algorithm: If TriggeringEnhancedInputAction is specified, visualize it else: If TriggeringInputAction is specified, visualize it else: If TriggeredInputAction is specified, visualize it else: Visualize the default click action while hovered

  • input_mode_override (CommonInputMode): [Read-Write] Set this to Game for special cases where an input action needs to be set for an in-game button.

  • input_priority (int32): [Read-Write] This is the priority for the TriggeringInputAction. The first, HIGHEST PRIORITY widget will handle the input action, and no other widgets will be considered. Additionally, no inputs with a priority below the current ActivatablePanel’s Input Priority value will even be considered! TODO:: This is part of legacy CommonUI and should be removed

  • interactable_when_selected (bool): [Read-Write] If true, the button may be clicked while selected. Otherwise, interaction is disabled in the selected state.

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

  • is_focusable (bool): [Read-Write] Setting this flag to true, allows this widget to accept focus when clicked, or when navigated to.

  • is_persistent_binding (bool): [Read-Write] DANGER! Be very, very careful with this. Unless you absolutely know what you’re doing, this is not the property you’re looking for.

    True to register the action bound to this button as a “persistent” binding. False (default) will register a standard activation-based binding. A persistent binding ignores the standard ruleset for UI input routing - the binding will be live immediately upon construction of the button.

  • 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.

  • locked (bool): [Read-Write] True if this button is currently locked. Locked button can be hovered, focused, and pressed, but the Click event will not go through. Business logic behind it will not be executed. Designed for progressive disclosure

  • locked_hovered_slate_sound_override (SlateSound): [Read-Write] Optional override for the sound to play when this button is hovered while Locked

  • locked_pressed_slate_sound_override (SlateSound): [Read-Write] Optional override for the sound to play when this button is pressed while Locked

  • min_height (int32): [Read-Write] The minimum height of the button (only used if greater than the style’s minimum)

  • min_width (int32): [Read-Write] The minimum width of the button (only used if greater than the style’s minimum)

  • 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.

  • on_button_base_clicked (CommonButtonBaseClicked): [Read-Write]

  • on_button_base_double_clicked (CommonButtonBaseClicked): [Read-Write]

  • on_button_base_hovered (CommonButtonBaseClicked): [Read-Write]

  • on_button_base_unhovered (CommonButtonBaseClicked): [Read-Write]

  • on_selected_changed_base (CommonSelectedStateChangedBase): [Read-Write]

  • on_visibility_changed (OnVisibilityChangedEvent): [Read-Write] Called when the visibility has changed

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

  • override_cursor (bool): [Read-Write]

  • padding (Margin): [Read-Write] The padding area around the content.

  • pixel_snapping (WidgetPixelSnapping): [Read-Write] If the widget will draw snapped to the nearest pixel. Improves clarity but might cause visibile stepping in animation

  • press_method (ButtonPressMethod): [Read-Write]

  • pressed_slate_sound_override (SlateSound): [Read-Write] Optional override for the sound to play when this button is pressed. Also used for the Selected and Locked Pressed state if their respective overrides are empty.

  • preview_background (Texture2D): [Read-Write] A preview background that you can use when designing the UI to get a sense of scale on the screen. Use a texture with a screenshot of your game in it, for example if you were designing a HUD.

  • priority (int32): [Read-Write]

  • 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.

  • requires_hold (bool): [Read-Write] True if this button should have a press and hold behavior, triggering the click when the specified hold time is met

  • selectable (bool): [Read-Write] True if the button supports being in a “selected” state, which will update the style accordingly

  • selected_hovered_slate_sound_override (SlateSound): [Read-Write] Optional override for the sound to play when this button is hovered while Selected

  • selected_pressed_slate_sound_override (SlateSound): [Read-Write] Optional override for the sound to play when this button is pressed while Selected

  • should_select_upon_receiving_focus (bool): [Read-Write] If true, the button will be selected when it receives focus.

  • should_use_fallback_default_input_action (bool): [Read-Write] True if this button should use the default fallback input action (bool is useful for buttons that shouldn’t because they are never directly hit via controller)

  • simulate_hover_on_touch_input (bool): [Read-Write] True if this button should play the hover effect when pressed by a touch input

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

  • stop_action (bool): [Read-Write]

  • style (type(Class)): [Read-Write] References the button style asset that defines a style in multiple sizes

  • tick_frequency (WidgetTickFrequency): [Read-Write] This widget is allowed to tick. If this is unchecked tick will never be called, animations will not play correctly, and latent actions will not execute. Uncheck this for performance reasons only

  • toggleable (bool): [Read-Write] True if the button can be deselected by clicking it when selected

  • 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

  • touch_method (ButtonTouchMethod): [Read-Write]

  • trigger_clicked_after_selection (bool): [Read-Write]

  • triggering_enhanced_input_action (InputAction): [Read-Write] The enhanced input action that is bound to this button. The common input manager will trigger this button to click if the action was pressed

  • triggering_input_action (DataTableRowHandle): [Read-Write] The input action that is bound to this button. The common input manager will trigger this button to click if the action was pressed

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

property apply_alpha_on_disable: bool

[Read-Only] The type of mouse action required by the user to trigger the button’s ‘Click’

Type:

(bool)

bp_on_clicked() None

BP on Clicked

bp_on_deselected() None

BP on Deselected

bp_on_disabled() None

BP on Disabled

bp_on_double_clicked() None

BP on Double Clicked

bp_on_enabled() None

BP on Enabled

bp_on_focus_lost() None

BP on Focus Lost

bp_on_focus_received() None

BP on Focus Received

bp_on_hovered() None

BP on Hovered

bp_on_input_action_triggered() None

BP on Input Action Triggered

bp_on_input_method_changed(current_input_type) None

BP on Input Method Changed

Parameters:

current_input_type (CommonInputType) –

bp_on_lock_clicked() None

BP on Lock Clicked

bp_on_lock_double_clicked() None

BP on Lock Double Clicked

bp_on_locked_changed(is_locked) None

BP on Locked Changed

Parameters:

is_locked (bool) –

bp_on_pressed() None

BP on Pressed

bp_on_released() None

BP on Released

bp_on_selected() None

BP on Selected

bp_on_unhovered() None

BP on Unhovered

clear_selection() None

Clear Selection

property click_event: WidgetEventField

[Read-Only]

Type:

(WidgetEventField)

property click_method: ButtonClickMethod

[Read-Only] The type of mouse action required by the user to trigger the button’s ‘Click’

Type:

(ButtonClickMethod)

disable_button_with_reason(disabled_reason) None

Disables this button with a reason (use instead of SetIsEnabled)

Parameters:

disabled_reason (Text) –

property display_input_action_when_not_interactable: bool

[Read-Only] True if the input action should be displayed when the button is not interactable

Type:

(bool)

get_current_button_padding() Margin
Returns:

out_button_padding (Margin):

Return type:

Margin

get_current_custom_padding() Margin
Returns:

out_custom_padding (Margin):

Return type:

Margin

get_current_text_style() CommonTextStyle
Returns:

The text style that corresponds to the current size and selection state

Return type:

CommonTextStyle

get_current_text_style_class()
Returns:

The class of the text style that corresponds to the current size and selection state

Return type:

type(Class)

get_enhanced_input_action() InputAction

Gets the appropriate enhanced input action that is set

Return type:

InputAction

get_input_action() DataTableRowHandle or None

Gets the appropriate input action that is set

Returns:

input_action_row (DataTableRowHandle):

Return type:

DataTableRowHandle or None

get_is_focusable() bool

Gets the bIsFocusable flag

Return type:

bool

get_locked() bool
Returns:

True if the button is currently locked, False otherwise

Return type:

bool

get_selected() bool
Returns:

True if the button is currently in a selected state, False otherwise

Return type:

bool

get_should_select_upon_receiving_focus() bool

Get whether the button should become selected upon receiving focus or not

Return type:

bool

get_single_material_style_mid() MaterialInstanceDynamic

Returns the dynamic instance of the material being used for this button, if it is using a single material style.

Return type:

MaterialInstanceDynamic

get_style() CommonButtonStyle
Returns:

Current button style

Return type:

CommonButtonStyle

property hide_input_action: bool

[Read-Only] Whether to hide the input action widget at all times (useful for textless small buttons)

Type:

(bool)

property hide_input_action_with_keyboard: bool

[Read-Only] True if the input action should be hidden while the user is using a keyboard

Type:

(bool)

property hold_data: Class

[Read-Only] Press and Hold values used for Keyboard and Mouse, Gamepad and Touch, depending on the current input type

Type:

(type(Class))

property hovered_slate_sound_override: SlateSound

[Read-Only] Optional override for the sound to play when this button is hovered. Also used for the Selected and Locked Hovered state if their respective overrides are empty.

Type:

(SlateSound)

property input_action_widget: CommonActionWidget

[Read-Only] Optionally bound widget for visualization behavior of an input action; NOTE: If specified, will visualize according to the following algorithm: If TriggeringEnhancedInputAction is specified, visualize it else: If TriggeringInputAction is specified, visualize it else: If TriggeredInputAction is specified, visualize it else: Visualize the default click action while hovered

Type:

(CommonActionWidget)

property input_priority: int

[Read-Only] This is the priority for the TriggeringInputAction. The first, HIGHEST PRIORITY widget will handle the input action, and no other widgets will be considered. Additionally, no inputs with a priority below the current ActivatablePanel’s Input Priority value will even be considered! TODO:: This is part of legacy CommonUI and should be removed

Type:

(int32)

property interactable_when_selected: bool

[Read-Only] If true, the button may be clicked while selected. Otherwise, interaction is disabled in the selected state.

Type:

(bool)

is_interaction_enabled() bool

Is this button currently interactable? (use instead of GetIsEnabled)

Return type:

bool

is_pressed() bool

Is this button currently pressed?

Return type:

bool

property locked: bool

[Read-Only] True if this button is currently locked. Locked button can be hovered, focused, and pressed, but the Click event will not go through. Business logic behind it will not be executed. Designed for progressive disclosure

Type:

(bool)

property locked_hovered_slate_sound_override: SlateSound

[Read-Only] Optional override for the sound to play when this button is hovered while Locked

Type:

(SlateSound)

property locked_pressed_slate_sound_override: SlateSound

[Read-Only] Optional override for the sound to play when this button is pressed while Locked

Type:

(SlateSound)

property min_height: int

[Read-Only] The minimum height of the button (only used if greater than the style’s minimum)

Type:

(int32)

property min_width: int

[Read-Only] The minimum width of the button (only used if greater than the style’s minimum)

Type:

(int32)

on_action_complete() None

Callback fired when hold events complete

on_action_progress(held_percent) None

Callback fired continously during hold interactions

Parameters:

held_percent (float) –

property on_button_base_clicked: CommonButtonBaseClicked

[Read-Write]

Type:

(CommonButtonBaseClicked)

property on_button_base_double_clicked: CommonButtonBaseClicked

[Read-Write]

Type:

(CommonButtonBaseClicked)

property on_button_base_hovered: CommonButtonBaseClicked

[Read-Write]

Type:

(CommonButtonBaseClicked)

property on_button_base_unhovered: CommonButtonBaseClicked

[Read-Write]

Type:

(CommonButtonBaseClicked)

on_current_text_style_changed() None

Allows derived classes to take action when the current text style has changed

property on_selected_changed_base: CommonSelectedStateChangedBase

[Read-Write]

Type:

(CommonSelectedStateChangedBase)

on_triggered_input_action_changed(new_triggered_action) None

Callback fired when input action datatable row changes

Parameters:

new_triggered_action (DataTableRowHandle) –

on_triggering_enhanced_input_action_changed(input_action) None

Callback fired when enhanced input action changes

Parameters:

input_action (InputAction) –

on_triggering_input_action_changed(new_triggered_action) None

Callback fired when triggered input action datatable row changes

Parameters:

new_triggered_action (DataTableRowHandle) –

property press_method: ButtonPressMethod

[Read-Only]

Type:

(ButtonPressMethod)

property pressed_slate_sound_override: SlateSound

[Read-Only] Optional override for the sound to play when this button is pressed. Also used for the Selected and Locked Pressed state if their respective overrides are empty.

Type:

(SlateSound)

property requires_hold: bool

[Read-Only] True if this button should have a press and hold behavior, triggering the click when the specified hold time is met

Type:

(bool)

property selectable: bool

[Read-Only] True if the button supports being in a “selected” state, which will update the style accordingly

Type:

(bool)

property selected_hovered_slate_sound_override: SlateSound

[Read-Only] Optional override for the sound to play when this button is hovered while Selected

Type:

(SlateSound)

property selected_pressed_slate_sound_override: SlateSound

[Read-Only] Optional override for the sound to play when this button is pressed while Selected

Type:

(SlateSound)

set_click_method(click_method) None

Set the click method for mouse interaction

Parameters:

click_method (ButtonClickMethod) –

set_hide_input_action(hide_input_action) None

Set Hide Input Action

Parameters:

hide_input_action (bool) –

set_hovered_sound_override(sound) None

Set Hovered Sound Override

Parameters:

sound (SoundBase) –

set_input_action_progress_material(progress_material_brush, progress_material_param) None

Set Input Action Progress Material

Parameters:
  • progress_material_brush (SlateBrush) –

  • progress_material_param (Name) –

set_is_focusable(is_focusable) None

Updates the bIsFocusable flag

Parameters:

is_focusable (bool) –

set_is_interactable_when_selected(interactable_when_selected) None

Change whether this widget is selectable at all. If false and currently selected, will deselect.

Parameters:

interactable_when_selected (bool) –

set_is_interaction_enabled(is_interaction_enabled) None

Change whether this widget is selectable at all. If false and currently selected, will deselect.

Parameters:

is_interaction_enabled (bool) –

set_is_locked(is_locked) None

Change whether this widget is locked. If locked, the button can be focusable and responsive to mouse input but will not broadcast OnClicked events.

Parameters:

is_locked (bool) –

set_is_selectable(is_selectable) None

Change whether this widget is selectable at all. If false and currently selected, will deselect.

Parameters:

is_selectable (bool) –

set_is_selected(selected, give_click_feedback=True) None

Change the selected state manually.

Parameters:
  • selected (bool) –

  • give_click_feedback (bool) – If true, the button may give user feedback as if it were clicked. IE: Play a click sound, trigger animations as if it were clicked.

set_is_toggleable(is_toggleable) None

Change whether this widget is toggleable. If toggleable, clicking when selected will deselect.

Parameters:

is_toggleable (bool) –

set_locked_hovered_sound_override(sound) None

Set Locked Hovered Sound Override

Parameters:

sound (SoundBase) –

set_locked_pressed_sound_override(sound) None

Set Locked Pressed Sound Override

Parameters:

sound (SoundBase) –

set_min_dimensions(min_width, min_height) None

Sets the minimum dimensions of this button

Parameters:
  • min_width (int32) –

  • min_height (int32) –

set_press_method(press_method) None

Set the click method for keyboard/gamepad button press interaction

Parameters:

press_method (ButtonPressMethod) –

set_pressed_sound_override(sound) None

Set Pressed Sound Override

Parameters:

sound (SoundBase) –

set_selected_hovered_sound_override(sound) None

Set Selected Hovered Sound Override

Parameters:

sound (SoundBase) –

set_selected_internal(selected, allow_sound=True, broadcast=True) None

Internal method to allow the selected state to be set regardless of selectability or toggleability

Parameters:
  • selected (bool) –

  • allow_sound (bool) –

  • broadcast (bool) –

set_selected_pressed_sound_override(sound) None

Set Selected Pressed Sound Override

Parameters:

sound (SoundBase) –

set_should_select_upon_receiving_focus(should_select_upon_receiving_focus) None

Set whether the button should become selected upon receiving focus or not; Only settable for buttons that are selectable

Parameters:

should_select_upon_receiving_focus (bool) –

set_should_use_fallback_default_input_action(should_use_fallback_default_input_action) None

Change whether this widget should use the fallback default input action.

Parameters:

should_use_fallback_default_input_action (bool) –

set_style(style=None) None

Sets the style of this button, rebuilds the internal styling

Parameters:

style (type(Class)) –

set_touch_method(touch_method) None

Set the click method for touch interaction

Parameters:

touch_method (ButtonTouchMethod) –

set_triggered_input_action(input_action_row) None

Updates the current triggered action

Parameters:

input_action_row (DataTableRowHandle) –

set_triggering_enhanced_input_action(input_action) None

Updates the current triggering enhanced input action, requires enhanced input enabled in CommonUI settings

Parameters:

input_action (InputAction) –

set_triggering_input_action(input_action_row) None

Updates the current triggering action

Parameters:

input_action_row (DataTableRowHandle) –

property should_select_upon_receiving_focus: bool

[Read-Only] If true, the button will be selected when it receives focus.

Type:

(bool)

property should_use_fallback_default_input_action: bool

[Read-Only] True if this button should use the default fallback input action (bool is useful for buttons that shouldn’t because they are never directly hit via controller)

Type:

(bool)

property simulate_hover_on_touch_input: bool

[Read-Only] True if this button should play the hover effect when pressed by a touch input

Type:

(bool)

stop_double_click_propagation() None

Unless this is called, we will assume the double click should be converted into a normal click.

property style: Class

[Read-Only] References the button style asset that defines a style in multiple sizes

Type:

(type(Class))

property toggleable: bool

[Read-Only] True if the button can be deselected by clicking it when selected

Type:

(bool)

property touch_method: ButtonTouchMethod

[Read-Only]

Type:

(ButtonTouchMethod)

property trigger_clicked_after_selection: bool

[Read-Only]

Type:

(bool)

property triggering_enhanced_input_action: InputAction

[Read-Only] The enhanced input action that is bound to this button. The common input manager will trigger this button to click if the action was pressed

Type:

(InputAction)

property triggering_input_action: DataTableRowHandle

[Read-Only] The input action that is bound to this button. The common input manager will trigger this button to click if the action was pressed

Type:

(DataTableRowHandle)