unreal.ScriptableModularBehaviorTool¶
- class unreal.ScriptableModularBehaviorTool(outer: Object | None = None, name: Name | str = 'None')¶
Bases:
ScriptableInteractiveToolA Scriptable tool base blueprint class which provides support for user defined mouse interaction behaviors
C++ Source:
Plugin: ScriptableToolsFramework
Module: ScriptableToolsFramework
File: ScriptableModularBehaviorTool.h
Editor Properties: (see get_editor_property/set_editor_property)
custom_icon_path(str): [Read-Write] deprecated: Use ToolIconTexture instead.custom_tool_builder_class(type(Class)): [Read-Write]group_tags(ScriptableToolGroupSet): [Read-Write] Tool Tagging Supportshow_tool_in_editor(bool): [Read-Write] A generic flag to indicate whether this Tool should be shown in the UE Editor. This may be interpreted in different waystool_category(Text): [Read-Write] Category of this Tool, will be used in (eg) Tool Palette Section headerstool_icon_texture(Texture2D): [Read-Write]tool_long_name(Text): [Read-Write] Long Name of this Tool, will be used in (eg) longer labels like the Accept/Cancel toolbartool_name(Text): [Read-Write] Name of this Tool, will be used in (eg) Toolbarstool_shutdown_type(ScriptableToolShutdownType): [Read-Write] Specifies how the user exits this Tool, either Accept/Cancel-style or Complete-styletool_startup_requirements(ScriptableToolStartupRequirements): [Read-Write]tool_target_tool_builder_class(type(Class)): [Read-Write]tool_tooltip(Text): [Read-Write] Tooltip used for this Tool in (eg) icons/etc
- add_click_drag_behavior(can_begin_click_drag_sequence, on_click_press, on_click_drag, on_click_release, on_terminate_drag_sequence, capture_check, capture_priority=100, mouse_button=ScriptableToolMouseButton.LEFT_BUTTON, update_modifiers_during_drag=False) None¶
Implements a standard “button-click-drag”-style input behavior.
- The state machine works as follows:
on input-device-button-press, call CanBeginClickDragSequence to determine if capture should begin
on input-device-move, call OnClickDrag
on input-device-button-release, call OnClickRelease
If a ForceEndCapture occurs we call OnTerminateDragSequence
- Parameters:
can_begin_click_drag_sequence (TestCanBeginClickDragSequenceDelegate) – Test if target can begin click-drag interaction at this point
on_click_press (OnClickPressDelegate) – Notify Target that click press occurred
on_click_drag (OnClickDragDelegate) – Notify Target that input position has changed
on_click_release (OnClickReleaseDelegate) – Notify Target that click release occurred
on_terminate_drag_sequence (OnTerminateDragSequenceDelegate) – Notify Target that click-drag sequence has been explicitly terminated (eg by escape key)
capture_check (MouseBehaviorModiferCheckDelegate) – Only enable capture if returns true
capture_priority (int32) – The priority is used to resolve situations where multiple behaviors want the same capture
mouse_button (ScriptableToolMouseButton) – Determines which mouse button the behavior captures on
update_modifiers_during_drag (bool)
- add_double_click_behavior(if_hit_by_click, on_hit_by_click, capture_check, capture_priority=100, mouse_button=ScriptableToolMouseButton.LEFT_BUTTON, hit_test_on_release=True) None¶
Implements a standard “button-click”-style input behavior The state machine works as follows:
on input-device-button-press, hit-test the target. If hit, begin capture
on input-device-button-release, hit-test the target. If hit, call OnHitByClick(). If not hit, ignore click.
The second hit-test is required to allow the click to be “cancelled” by moving away from the target. This is standard GUI behavior. You can disable this second hit test using the HitTestOnRelease property. This is strongly discouraged.
- Parameters:
if_hit_by_click (TestIfHitByClickDelegate) – Test if hit by a click
on_hit_by_click (OnHitByClickDelegate) – Notify that double click occurred
capture_check (MouseBehaviorModiferCheckDelegate) – Only enable capture if returns true
capture_priority (int32) – The priority is used to resolve situations where multiple behaviors want the same capture
mouse_button (ScriptableToolMouseButton) – Determines which mouse button the behavior captures on
hit_test_on_release (bool)
- add_mouse_hover_behavior(begin_hover_sequence_hit_test, on_begin_hover, on_update_hover, on_end_hover, hover_capture_check, capture_priority=100) None¶
- Parameters:
begin_hover_sequence_hit_test (BeginHoverSequenceHitTestDelegate) – Do hover hit-test
on_begin_hover (OnBeginHoverDelegate) – Initialize hover sequence at given position
on_update_hover (OnUpdateHoverDelegate) – Update active hover sequence with new input position
on_end_hover (OnEndHoverDelegate) – Terminate active hover sequence
hover_capture_check (MouseBehaviorModiferCheckDelegate) – Only enable hover capture if returns true
capture_priority (int32) – The priority is used to resolve situations where multiple behaviors want the same capture
- add_mouse_wheel_behavior(test_should_respond_to_mouse_wheel, on_mouse_wheel_scroll_up, on_mouse_wheel_scroll_down, capture_check, capture_priority=100) None¶
- Parameters:
test_should_respond_to_mouse_wheel (TestShouldRespondToMouseWheelDelegate) – The result’s bHit property determines whether the mouse wheel action will be captured. (Perhaps the mouse wheel only does something when mousing over some part of a mesh)
on_mouse_wheel_scroll_up (OnMouseWheelScrollUpDelegate) – CurrentPos device position/ray at point where mouse wheel is engaged
on_mouse_wheel_scroll_down (OnMouseWheelScrollDownDelegate) – CurrentPos device position/ray at point where mouse wheel is engaged
capture_check (MouseBehaviorModiferCheckDelegate) – Only enable capture if returns true
capture_priority (int32) – The priority is used to resolve situations where multiple behaviors want the same capture
- add_multi_click_sequence_behavior(on_begin_sequence_preview, can_begin_click_sequence, on_begin_click_sequence, on_next_sequence_preview, on_next_sequence_click, on_terminate_click_sequence, request_abort_click_sequence, capture_check, hover_capture_check, capture_priority=100, mouse_button=ScriptableToolMouseButton.LEFT_BUTTON) None¶
MultiClickSequenceBehavior implements a generic multi-click-sequence input behavior. For example this behavior could be used to implement a multi-click polygon-drawing interaction.
- The internal state machine works as follows:
on input-device-button-press, check if target wants to begin sequence. If so, begin capture.
- on button release, check if target wants to continue or terminate sequence
if terminate, release capture
if continue, do nothing (capture continues between presses)
The target will receive “preview” notifications (basically hover) during updates where there is not a release. This can be used to (eg) update a rubber-band selection end point
- Parameters:
on_begin_sequence_preview (OnBeginSequencePreviewDelegate) – Notify Target device position has changed but a click sequence hasn’t begun yet (eg for interactive previews)
can_begin_click_sequence (CanBeginClickSequenceDelegate) – Test if target would like to begin sequence based on this click. Gets checked both on mouse down and mouse up.
on_begin_click_sequence (OnBeginClickSequenceDelegate) – Notify Target about the first click in the sequence.
on_next_sequence_preview (OnNextSequencePreviewDelegate) – Notify Target device position has changed but a click hasn’t occurred yet (eg for interactive previews)
on_next_sequence_click (OnNextSequenceClickDelegate) – Notify Target about next click in sqeuence, returns false to terminate sequence
on_terminate_click_sequence (OnTerminateClickSequenceDelegate) – Notify Target that click sequence has been explicitly terminated (eg by escape key, cancel tool, etc).
request_abort_click_sequence (RequestAbortClickSequenceDelegate) – Target overrides this and returns true if it wants to abort click sequence, checked every update
capture_check (MouseBehaviorModiferCheckDelegate) – Only enable capture if returns true
hover_capture_check (MouseBehaviorModiferCheckDelegate) – Only enable hover capture if returns true
capture_priority (int32) – The priority is used to resolve situations where multiple behaviors want the same capture
mouse_button (ScriptableToolMouseButton) – Determines which mouse button the behavior captures on
- add_multi_key_input_behavior(on_key_pressed, on_key_released, on_force_end_capture_func_in, keys, require_all_keys, capture_check, capture_priority) None¶
AddMultiKeyInputBehavior implements a generic keyboard multi key listener behavior
- Parameters:
on_key_pressed (OnKeyStateToggleDelegate) – Callback when the target key(s) is pressed. Only triggers once if bRequireAllKeys is true.
on_key_released (OnKeyStateToggleDelegate) – Callback when the target key(s) is pressed. Only triggers once if bRequireAllKeys is true.
on_force_end_capture_func_in (OnForceEndCaptureDelegate_ScriptableTools) – Callback when capture is ended prematurely, typically due to the viewport losing focus, in which case the release callback will not be called.
require_all_keys (bool) – If true, all target keys must be pressed simultaniously to recieve press/release events. Otherwise, any and all keys can trigger events.
capture_check (MouseBehaviorModiferCheckDelegate) – Only enable capture if returns true
capture_priority (int32) – The priority is used to resolve situations where multiple behaviors want the same capture
- add_single_click_behavior(if_hit_by_click, on_hit_by_click, capture_check, capture_priority=100, mouse_button=ScriptableToolMouseButton.LEFT_BUTTON, hit_test_on_release=True) None¶
Implements a standard “button-click”-style input behavior The state machine works as follows:
on input-device-button-press, hit-test the target. If hit, begin capture
on input-device-button-release, hit-test the target. If hit, call OnHitByClick(). If not hit, ignore click.
The second hit-test is required to allow the click to be “cancelled” by moving away from the target. This is standard GUI behavior. You can disable this second hit test using the HitTestOnRelease property. This is strongly discouraged.
- Parameters:
if_hit_by_click (TestIfHitByClickDelegate) – Test if hit by a click
on_hit_by_click (OnHitByClickDelegate) – Notify that click occurred
capture_check (MouseBehaviorModiferCheckDelegate) – Only enable capture if returns true
capture_priority (int32) – The priority is used to resolve situations where multiple behaviors want the same capture
mouse_button (ScriptableToolMouseButton) – Determines which mouse button the behavior captures on
hit_test_on_release (bool)
- add_single_click_or_drag_behavior(if_hit_by_click, on_hit_by_click, can_begin_click_drag_sequence, on_click_press, on_click_drag, on_click_release, on_terminate_drag_sequence, capture_check, capture_priority=100, mouse_button=ScriptableToolMouseButton.LEFT_BUTTON, begin_drag_if_click_target_not_hit=True, click_distance_threshold=5.000000) None¶
SingleClickOrDragBehavior is a combination of a SingleClickBehavior and ClickDragBehavior, and allows for the common UI interaction where a click-and-release does one action, but if the mouse is moved, then a drag interaction is started. For example click-to-select is often combined with a drag-marquee-rectangle in this way. This can be directly implemented with a ClickDragBehavior but requires the client to (eg) detect movement thresholds, etc. This class encapsulates all that state/logic.
The ClickDistanceThreshold parameter determines how far the mouse must move (in whatever device units are in use) to switch from a click to drag interaction
The bBeginDragIfClickTargetNotHit parameter determines if the drag interaction will be immediately initiated if the initial ‘click’ mouse-down does not hit a valid clickable target. Defaults to true.
- Parameters:
if_hit_by_click (TestIfHitByClickDelegate) – Test if hit by a click
on_hit_by_click (OnHitByClickDelegate) – Notify that click occurred
can_begin_click_drag_sequence (TestCanBeginClickDragSequenceDelegate) – Test if target can begin click-drag interaction at this point
on_click_press (OnClickPressDelegate) – Notify Target that click press occurred
on_click_drag (OnClickDragDelegate) – Notify Target that input position has changed
on_click_release (OnClickReleaseDelegate) – Notify Target that click release occurred
on_terminate_drag_sequence (OnTerminateDragSequenceDelegate) – Notify Target that click-drag sequence has been explicitly terminated (eg by escape key)
capture_check (MouseBehaviorModiferCheckDelegate) – Only enable capture if returns true
capture_priority (int32) – The priority is used to resolve situations where multiple behaviors want the same capture
mouse_button (ScriptableToolMouseButton) – Determines which mouse button the behavior captures on
begin_drag_if_click_target_not_hit (bool)
click_distance_threshold (float)
- add_single_key_input_behavior(on_key_pressed, on_key_released, on_force_end_capture_func_in, key, capture_check, capture_priority) None¶
AddSingleKeyInputBehavior implements a generic keyboard key listener behavior
- Parameters:
on_key_pressed (OnKeyStateToggleDelegate) – Callback when the target key is pressed.
on_key_released (OnKeyStateToggleDelegate) – Callback when the target key is released
on_force_end_capture_func_in (OnForceEndCaptureDelegate_ScriptableTools) – Callback when capture is ended prematurely, typically due to the viewport losing focus, in which case the release callback will not be called.
key (Key)
capture_check (MouseBehaviorModiferCheckDelegate) – Only enable capture if returns true
capture_priority (int32) – The priority is used to resolve situations where multiple behaviors want the same capture
- get_active_modifiers() ScriptableToolModifierStates¶
- Returns:
a struct containing the current Modifier key states
- Return type: