Skip to content

UDraggableWindow

#include <DraggableWindowUMG/DraggableWindow.h>
class UDraggableWindow

Defined in DraggableWindow.h:18

Inherits: UUserWidget

---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class UDraggableWindow["UDraggableWindow"]
  class UUserWidget["UUserWidget"]
  UUserWidget <|-- UDraggableWindow
---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class UDraggableWindow["UDraggableWindow"]
  class EOperatingSystemWindowStartupState["EOperatingSystemWindowStartupState"]
  UDraggableWindow ..> EOperatingSystemWindowStartupState
---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class UDraggableWindow {
    +UDraggableWindow(const FObjectInitializer &ObjectInitializer
    +SetWindowTitle(const FText &NewTitle)
    +CloseWindow()
    +GetWindowPosition() const TOptional< FVector2D >
    +AddContentWidgetClass(TSubclassOf< class UUserWidget > InWidgetCl
    +AddContentWidget(class UUserWidget *InWidget, const bool bCl
    +ToggleMaximize() bool
    +CenterWindowToScreen()
    +UpdateWindowSize(const FVector2D &InNewSize) bool
    +GetChildWidget(UUserWidget *&OutChildWidget) const bool
    +SetPosition(const FVector2D NewPosition)
    +IsMaximized() const bool
    +CreateDraggableWindow(const UObject *WorldContextObject, TSubclas UDraggableWindow() *
    +CreateDraggableWindowFromWidget(const UObject *WorldContextObject, TSubclas UDraggableWindow() *
    +bEnableDrag : uint8
    +bEnableResizing : uint8
    +bEnableMaximizing : uint8
    +MaximizeTaskbarOffset : float
    +ResizeMinWidth : float
    +ResizeMaxWidth : float
    +ResizeMinHeight : float
    +ResizeMaxHeight : float
    +DragKey : FKey
    +WindowTitleBorderWidget : UBorder *
    +ChildWidgetCanvas : UCanvasPanel *
    +ResizeAreaWidget : UBorder *
    +ParentSlot : UCanvasPanelSlot *
    +ChildWidget : UUserWidget *
    +bIsMaximized : uint8
    +LastMousePosition : FVector2D
    +PreResizeAlignment : FVector2D
    +PreResizeOffset : FVector2D
    +PreDragSize : FVector2D
    +StartSize : FVector2D
    +CurrentZOrder : int32
    +PreFullscreenAnchors : FAnchors
    +PreFullscreenMargin : FMargin
    +StartupState : EOperatingSystemWindowStartupState()
    +NativeConstruct() override
    +NativeOnMouseMove(const FGeometry &InGeometry, const FPointer FReply
    +NativeOnMouseButtonUp(const FGeometry &InGeometry, const FPointer FReply
    +OnCloseWindow()
    +K2_OnCloseWindow()
    +K2_OnSetWindowTitle(const FText &NewWindowTitle)
    +K2_OnContentWidgetAdded(const UUserWidget *AddedUserWidget)
    +K2_OnDragStart(const FPointerEvent &InMouseEvent)
    +K2_OnResizeStart(const FPointerEvent &InMouseEvent)
    +K2_StartMinimized()
    +K2_OnWindowMaximizeToggled()
    +Internal_OnMouseButtonUpEvent()
    +Internal_DetermineNewSize(const FVector2D &InDelta) const FVector2D
    +Internal_OnMouseButtonUp_WindowTitleBorder(FGeometry InGeometry, const FPointerEvent & FEventReply
    +Internal_OnMouseButtonDown_WindowTitleBorder(FGeometry InGeometry, const FPointerEvent & FEventReply
    +Internal_OnMouseButtonDown_ResizeArea(FGeometry InGeometry, const FPointerEvent & FEventReply
    +Internal_AddContentWidget(const bool bClearPrevious)
  }

User widget class that represents a draggable window widget. It allows users to create draggable windows with optional resizing and maximizing features.

ReturnNameDescription
UDraggableWindow
voidSetWindowTitle inlineSets the title of the window.
voidCloseWindowCloses the draggable window.
TOptional< FVector2D >GetWindowPosition constGet the position of the draggable window.
voidAddContentWidgetClassAdds a content to this window. A new widget is created from the given class.
voidAddContentWidgetAdds a content to this window.
boolToggleMaximizeMaximizes or restores this window.
voidCenterWindowToScreenCenter this window to screen. Will not work if window is maximized.
boolUpdateWindowSizeUpdates the size of the draggable window.
boolGetChildWidget constReturns the child widget (if any) of this draggable window. If the Return Value is true, then OutChildWidget will be valid.
voidSetPositionSet the position of the window to the specified coordinates.
boolIsMaximized const inlineReturns whether the window is currently maximized.

UDraggableWindow(const FObjectInitializer & ObjectInitializer)

Defined in DraggableWindow.h:206


inline

inline void SetWindowTitle(const FText & NewTitle)

Defined in DraggableWindow.h:286 Sets the title of the window.

  • NewTitle The new title of the window.

void CloseWindow()

Defined in DraggableWindow.h:300 Closes the draggable window.

This method is used to close the draggable window. It performs the following steps:

  1. Calls the K2_OnCloseWindow() function.

  2. Calls the OnCloseWindow() function.

  3. Clears the children of the ChildWidgetCanvas if it is valid.

  4. Removes the draggable window from its parent.


const

TOptional< FVector2D > GetWindowPosition() const

Defined in DraggableWindow.h:310 Get the position of the draggable window.

This method retrieves the position of the draggable window. It checks if the ParentSlot is valid, and if so, it calls GetPosition() on the ParentSlot to get the window position. If the ParentSlot is not valid, it returns an empty TOptional<FVector2D> object.

The position of the draggable window, or an empty TOptional<FVector2D> object if the ParentSlot is not valid.


void AddContentWidgetClass(TSubclassOf< class UUserWidget > InWidgetClass, const bool bClearPrevious = true)

Defined in DraggableWindow.h:320 Adds a content to this window. A new widget is created from the given class.

@See AddContentWidget().

  • InWidgetClass [TSubclassOf<class UUserWidget>] Widget class to use as content for this window.

  • bClearPrevious [const bool] Should we clear all existing children from Child Widget Canvas? Recommended to keep this on.


void AddContentWidget(class UUserWidget * InWidget, const bool bClearPrevious = true)

Defined in DraggableWindow.h:330 Adds a content to this window.

@See AddContentWidgetClass().

  • InWidget [class UUserWidget*] Reference to an existing content.

  • bClearPrevious [const bool] Should we clear all existing children from Child Widget Canvas? Recommended to keep this on.


bool ToggleMaximize()

Defined in DraggableWindow.h:338 Maximizes or restores this window.

[bool] True if the window was maximized or restored.


void CenterWindowToScreen()

Defined in DraggableWindow.h:344 Center this window to screen. Will not work if window is maximized.


bool UpdateWindowSize(const FVector2D & InNewSize)

Defined in DraggableWindow.h:353 Updates the size of the draggable window.

  • InNewSize [const FVector2D&] New size to change to.

[bool] True if the size was changed successfully.


const

bool GetChildWidget(UUserWidget *& OutChildWidget) const

Defined in DraggableWindow.h:362 Returns the child widget (if any) of this draggable window. If the Return Value is true, then OutChildWidget will be valid.

  • OutChildWidget [UUserWidget*&] Reference to the child widget created by this window.

[bool] True if a valid child widget is available.


void SetPosition(const FVector2D NewPosition)

Defined in DraggableWindow.h:373 Set the position of the window to the specified coordinates.

  • NewPosition The new position of the window as a 2D vector (FVector2D).

const inline

inline bool IsMaximized() const

Defined in DraggableWindow.h:447 Returns whether the window is currently maximized.

True if the window is maximized, false otherwise.

ReturnNameDescription
UDraggableWindow *CreateDraggableWindow staticpublic static UDraggableWindow::CreateDraggableWindow Creates a draggable window widget instance from given widget class. You can optionally add a child widget also which will be the content for this window.
UDraggableWindow *CreateDraggableWindowFromWidget staticpublic static UDraggableWindow::CreateDraggableWindowFromWidget Creates a draggable window widget instance from given widget class. You can optionally add a child widget also which will be the content for this window.

static

static UDraggableWindow * CreateDraggableWindow(const UObject * WorldContextObject, TSubclassOf< UDraggableWindow > WindowClass, TSubclassOf< UUserWidget > ChildWidgetClass, const FVector2D StartSize = FVector2D(640.f, 480.f), const FVector2D ResizeWidth = FVector2D(640.f, 480.f), const FVector2D ResizeHeight = FVector2D(0.f, 0.f), const bool bCenterToScreen = true, const bool bCanDrag = true, const bool bCanResize = true, const EOperatingSystemWindowStartupState WindowStartupState = EOperatingSystemWindowStartupState::Default)

Defined in DraggableWindow.h:224 public static UDraggableWindow::CreateDraggableWindow Creates a draggable window widget instance from given widget class. You can optionally add a child widget also which will be the content for this window.

  • WorldContextObject [const UObject*] World context object.

  • WindowClass [TSubclassOf<UDraggableWindow>] Window widget class to create.

  • ChildWidgetClass [TSubclassOf<UUserWidget>] [OPTIONAL] Child content class to add to the newly created window widget.

  • StartSize [const FVector2D] What size should we start the window.

  • ResizeWidth [const FVector2D] Min (X) and Max (Y) width of this window.

  • ResizeHeight [const FVector2D] Min (X) and Max (Y) height of this window.

  • bCenterToScreen [const bool] Should we center the window to the player screen.

  • bCanDrag [const bool] Determines if the window can be dragged.

  • bCanResize [const bool] Determines if the window can be resized (You must have a Border widget with Is Variable set to true and variable name set to ResizeAreaWidget).

  • WindowStartupState [const EOperatingSystemWindowStartupState] Window state to apply.

[UDraggableWindow*] Newly created window widget.


static

static UDraggableWindow * CreateDraggableWindowFromWidget(const UObject * WorldContextObject, TSubclassOf< UDraggableWindow > WindowClass, UUserWidget * NewChildWidget, const FVector2D StartSize = FVector2D(640.f, 480.f), const FVector2D ResizeWidth = FVector2D(640.f, 480.f), const FVector2D ResizeHeight = FVector2D(0.f, 0.f), const bool bCenterToScreen = true, const bool bCanDrag = true, const bool bCanResize = true, const EOperatingSystemWindowStartupState WindowStartupState = EOperatingSystemWindowStartupState::Default)

Defined in DraggableWindow.h:249 public static UDraggableWindow::CreateDraggableWindowFromWidget Creates a draggable window widget instance from given widget class. You can optionally add a child widget also which will be the content for this window.

  • WorldContextObject [const UObject*] World context object.

  • WindowClass [TSubclassOf<UDraggableWindow>] Window widget class to create.

  • NewChildWidget [UUserWidget*] [OPTIONAL] Child content to add to the newly created window widget.

  • StartSize [const FVector2D] What size should we start the window.

  • ResizeWidth [const FVector2D] Min (X) and Max (Y) width of this window.

  • ResizeHeight [const FVector2D] Min (X) and Max (Y) height of this window.

  • bCenterToScreen [const bool] Should we center the window to the player screen.

  • bCanDrag [const bool] Determines if the window can be dragged.

  • bCanResize [const bool] Determines if the window can be resized (You must have a Border widget with Is Variable set to true and variable name set to ResizeAreaWidget).

  • WindowStartupState [const EOperatingSystemWindowStartupState] Window state to apply.

[UDraggableWindow*] Newly created window widget.

ReturnNameDescription
uint8bEnableDrag
uint8bEnableResizing
uint8bEnableMaximizing
floatMaximizeTaskbarOffset
floatResizeMinWidth
floatResizeMaxWidth
floatResizeMinHeight
floatResizeMaxHeight
FKeyDragKey
UBorder *WindowTitleBorderWidgetA pointer to a UBorder widget that represents the window title border.
UCanvasPanel *ChildWidgetCanvasPointer to a UCanvasPanel object representing the child widget canvas of the draggable window.
UBorder *ResizeAreaWidgetRepresents the resize area widget of the draggable window widget.
UCanvasPanelSlot *ParentSlotA canvas panel slot is responsible for defining the layout and positioning of a widget within a canvas panel. The ParentSlot variable is used to access and manipulate the properties of the canvas panel slot associated with the parent widget.
UUserWidget *ChildWidgetRepresents a child widget of a draggable window.
uint8bIsMaximizedFlag indicating if the draggable window is maximized.
FVector2DLastMousePositionThe last recorded mouse position.
FVector2DPreResizeAlignmentA 2D vector that represents the alignment of a draggable window before resizing.
FVector2DPreResizeOffsetOffset value used for pre-resizing calculations.
FVector2DPreDragSizePreDragSize is a variable of type FVector2D. It represents the size of the draggable window before it is dragged.
FVector2DStartSizeRepresents the starting size of the draggable window.
int32CurrentZOrderThe current Z-order of the window.
FAnchorsPreFullscreenAnchorsThe PreFullscreenAnchors variable is of type FAnchors and is used to store the original anchors of a draggable window before it enters fullscreen mode.
FMarginPreFullscreenMarginThis variable is of type FMargin, which is a struct that represents a rectangle’s margin. It is used to store the top, left, bottom, and right margins of the window before it enters full screen mode.
EOperatingSystemWindowStartupStateStartupStateEnum representing the startup state of an operating system window.

uint8 bEnableDrag

Defined in DraggableWindow.h:26


uint8 bEnableResizing

Defined in DraggableWindow.h:30


uint8 bEnableMaximizing

Defined in DraggableWindow.h:34


float MaximizeTaskbarOffset

Defined in DraggableWindow.h:38


float ResizeMinWidth

Defined in DraggableWindow.h:42


float ResizeMaxWidth

Defined in DraggableWindow.h:46


float ResizeMinHeight

Defined in DraggableWindow.h:50


float ResizeMaxHeight

Defined in DraggableWindow.h:54


FKey DragKey

Defined in DraggableWindow.h:58


UBorder * WindowTitleBorderWidget

Defined in DraggableWindow.h:71 A pointer to a UBorder widget that represents the window title border.

This variable is used in the DraggableWindow class to reference the UBorder widget that represents the window title border. The UBorder widget is a visual element that can be customized to display the title of the window and provide a draggable area for the window.

See also: DraggableWindow


UCanvasPanel * ChildWidgetCanvas

Defined in DraggableWindow.h:79 Pointer to a UCanvasPanel object representing the child widget canvas of the draggable window.


UBorder * ResizeAreaWidget

Defined in DraggableWindow.h:88 Represents the resize area widget of the draggable window widget.

The resize area widget is used to specify the area where the user can click and drag to resize the window. If this widget is null, resizing will not be enabled for the window.


UCanvasPanelSlot * ParentSlot

Defined in DraggableWindow.h:97 A canvas panel slot is responsible for defining the layout and positioning of a widget within a canvas panel. The ParentSlot variable is used to access and manipulate the properties of the canvas panel slot associated with the parent widget.


UUserWidget * ChildWidget

Defined in DraggableWindow.h:106 Represents a child widget of a draggable window.

This variable is of type UUserWidget*. It represents a child widget that can be attached to a draggable window. The child widget will be displayed within the draggable window and can be manipulated along with it.


uint8 bIsMaximized

Defined in DraggableWindow.h:126 Flag indicating if the draggable window is maximized.

This flag is used to determine if the draggable window is currently maximized. It is a boolean flag with a width of 1 bit. When the flag is set to true (1), it means that the draggable window is maximized. When the flag is set to false (0), it means that the draggable window is not maximized.


FVector2D LastMousePosition

Defined in DraggableWindow.h:143 The last recorded mouse position.

This variable stores the last known position of the mouse on the screen. It is of type FVector2D, which represents a 2D vector with X and Y coordinates. The X coordinate represents the horizontal position of the mouse, and the Y coordinate represents the vertical position of the mouse.

To access this variable, use the appropriate getter and setter methods provided by the class or structure that contains it. The methods should be named in accordance with the coding conventions and naming conventions followed in the application.


FVector2D PreResizeAlignment

Defined in DraggableWindow.h:150 A 2D vector that represents the alignment of a draggable window before resizing.

This vector stores the alignment of a draggable window before it is resized. It is used to determine the original position of the window before resizing it.


FVector2D PreResizeOffset

Defined in DraggableWindow.h:153 Offset value used for pre-resizing calculations.


FVector2D PreDragSize

Defined in DraggableWindow.h:160 PreDragSize is a variable of type FVector2D. It represents the size of the draggable window before it is dragged.

PreDragSize is typically updated whenever the size of the draggable window changes, but before it is actually dragged. It is useful for keeping track of the previous size of the window.


FVector2D StartSize

Defined in DraggableWindow.h:174 Represents the starting size of the draggable window.

This variable is of type FVector2D, which is a structure that holds a 2D vector. The vector represents the width and height of the window.

The StartSize variable is used to define the initial size of the draggable window when it is created. It determines the width and height of the window before any user interaction or resizing occurs.

See also: CreateDraggableWindowFromWidget


int32 CurrentZOrder

Defined in DraggableWindow.h:185 The current Z-order of the window.

The Z-order determines the position of the window relative to other windows in the stacking order. A higher Z-order means the window will be displayed above windows with lower Z-orders.


FAnchors PreFullscreenAnchors

Defined in DraggableWindow.h:188 The PreFullscreenAnchors variable is of type FAnchors and is used to store the original anchors of a draggable window before it enters fullscreen mode.


FMargin PreFullscreenMargin

Defined in DraggableWindow.h:191 This variable is of type FMargin, which is a struct that represents a rectangle’s margin. It is used to store the top, left, bottom, and right margins of the window before it enters full screen mode.


EOperatingSystemWindowStartupState StartupState

Defined in DraggableWindow.h:202 Enum representing the startup state of an operating system window.

The EOperatingSystemWindowStartupState enumeration represents the possible startup states for an operating system window. It is used to define how a window should behave when it is initially displayed.

See also: CreateDraggableWindowFromWidget

ReturnNameDescription
voidNativeConstruct virtual override
FReplyNativeOnMouseMove virtual override
FReplyNativeOnMouseButtonUp virtual override
voidOnCloseWindow virtual inlineThis virtual function is called when the window is being closed. It can be overridden by derived classes to provide custom behavior when the window is closed.
voidK2_OnCloseWindowprotected UDraggableWindow::K2_OnCloseWindow Event called when this window is closed. C++ implementation calls RemoveFromParent automatically.
voidK2_OnSetWindowTitleprotected UDraggableWindow::K2_OnSetWindowTitle Event called when a new title is set for this window.
voidK2_OnContentWidgetAddedprotected UDraggableWindow::K2_OnContentWidgetAdded Event called when a new content is added to this window.
voidK2_OnDragStartprotected UDraggableWindow::K2_OnDragStart Event called when resizing is started. Only called if Enable Drag is true.
voidK2_OnResizeStartprotected UDraggableWindow::K2_OnResizeStart Event called when resizing is started. Only called if Enable Resizing is true.
voidK2_StartMinimizedprotected UDraggableWindow::K2_StartMinimized Event called when the window starts minimized.
voidK2_OnWindowMaximizeToggledprotected UDraggableWindow::K2_OnWindowMaximizeToggled Event called when this window is maximized or restored.

virtual override

virtual void NativeConstruct() override

Defined in DraggableWindow.h:261


virtual override

virtual FReply NativeOnMouseMove(const FGeometry & InGeometry, const FPointerEvent & InMouseEvent) override

Defined in DraggableWindow.h:262


virtual override

virtual FReply NativeOnMouseButtonUp(const FGeometry & InGeometry, const FPointerEvent & InMouseEvent) override

Defined in DraggableWindow.h:263


virtual inline

virtual inline void OnCloseWindow()

Defined in DraggableWindow.h:385 This virtual function is called when the window is being closed. It can be overridden by derived classes to provide custom behavior when the window is closed.


void K2_OnCloseWindow()

Defined in DraggableWindow.h:392 protected UDraggableWindow::K2_OnCloseWindow Event called when this window is closed. C++ implementation calls RemoveFromParent automatically.


void K2_OnSetWindowTitle(const FText & NewWindowTitle)

Defined in DraggableWindow.h:400 protected UDraggableWindow::K2_OnSetWindowTitle Event called when a new title is set for this window.

  • NewWindowTitle [const FText &] New title.

void K2_OnContentWidgetAdded(const UUserWidget * AddedUserWidget)

Defined in DraggableWindow.h:408 protected UDraggableWindow::K2_OnContentWidgetAdded Event called when a new content is added to this window.

  • AddedUserWidget [const UUserWidget*] Reference to the content that is being added.

void K2_OnDragStart(const FPointerEvent & InMouseEvent)

Defined in DraggableWindow.h:416 protected UDraggableWindow::K2_OnDragStart Event called when resizing is started. Only called if Enable Drag is true.

  • InMouseEvent [const FPointerEvent&] Mouse or touch action.

void K2_OnResizeStart(const FPointerEvent & InMouseEvent)

Defined in DraggableWindow.h:424 protected UDraggableWindow::K2_OnResizeStart Event called when resizing is started. Only called if Enable Resizing is true.

  • InMouseEvent [const FPointerEvent&] Mouse or touch action.

void K2_StartMinimized()

Defined in DraggableWindow.h:431 protected UDraggableWindow::K2_StartMinimized Event called when the window starts minimized.


void K2_OnWindowMaximizeToggled()

Defined in DraggableWindow.h:438 protected UDraggableWindow::K2_OnWindowMaximizeToggled Event called when this window is maximized or restored.

ReturnNameDescription
voidInternal_OnMouseButtonUpEvent
FVector2DInternal_DetermineNewSize const
FEventReplyInternal_OnMouseButtonUp_WindowTitleBorder
FEventReplyInternal_OnMouseButtonDown_WindowTitleBorder
FEventReplyInternal_OnMouseButtonDown_ResizeArea
voidInternal_AddContentWidget

void Internal_OnMouseButtonUpEvent()

Defined in DraggableWindow.h:267


const

FVector2D Internal_DetermineNewSize(const FVector2D & InDelta) const

Defined in DraggableWindow.h:268


Internal_OnMouseButtonUp_WindowTitleBorder

Section titled “Internal_OnMouseButtonUp_WindowTitleBorder”
FEventReply Internal_OnMouseButtonUp_WindowTitleBorder(FGeometry InGeometry, const FPointerEvent & InMouseEvent)

Defined in DraggableWindow.h:271


Internal_OnMouseButtonDown_WindowTitleBorder

Section titled “Internal_OnMouseButtonDown_WindowTitleBorder”
FEventReply Internal_OnMouseButtonDown_WindowTitleBorder(FGeometry InGeometry, const FPointerEvent & InMouseEvent)

Defined in DraggableWindow.h:274


FEventReply Internal_OnMouseButtonDown_ResizeArea(FGeometry InGeometry, const FPointerEvent & InMouseEvent)

Defined in DraggableWindow.h:277


void Internal_AddContentWidget(const bool bClearPrevious)

Defined in DraggableWindow.h:377