I’ve implemented Drag & Drop for one widget blueprint using a DragDropOperation object. This is working nice but the player controller always uses the default mouse cursor during the dragging. Even when it’s not the default cursor specified in the player controller.
Does anyone have an idea how to change this? I’ve tried setting the current mouse cursor in the OnDragDetected event but this doesn’t work.
Problem is that the Blueprint DragAndDropOperation is a UDragAndDropOperation and not a FDragAndDropOperation so we have no way to override the mouse cursor… Maybe it will help you.
In project settings there is an option for setting the cursor design using a widget. Making this empty also can ‘hide’ the cursor. (‘Empty’ being the created widgetbp)
and in the case of just using the standard cursor, when dragging a widget I would like it to change to the hand cursor and when releasing it to return to the default, I tried to do it here but when I try to drag it continues with the default cursor then after I release it it changes to the hand cursor
I couldn’t find a solution. The only thing I did was do as my friend Macarmoni said, put a transparent cursor in place of the default in the game settings and when the game starts change the cursor to a secondary one so that it is not always transparent, only when dragging and dropping, it’s a gimmick unfortunately
Easier fix: in FUMGDragDropOp::OnCursorQuery() it uses SourceUserWidgetPtr’s overriden pointer if it exists (the object you’re starting the drag from). So enable the checkbox to override the cursor on that widget, then set the overriden cursor to whatever you want it to be at various stages. GrabHand when the mouse enters, Default when it leaves, GrabHandClosed when the drag is triggered, etc.
When using hardware cursors, make sure the cursor file is not an imported .uasset, you need the files in the correct directory, but not actually imported to the engine.
Go to Project Settings → Engine - User Interface → Hardware Cursors and define a directory where your cursor images are stored. Use your game name (content root folder) for the relative path.
For example, you need cursor_hand.png not cursor_hand.uasset. The png file will not actually be visible in the content browser in engine, but can be read this way. No need to add the file extension for the function call either, just the name.