I have been following an inventory tutorial from UE4 that is about 5-6 years old. Amazingly enough, the code works well other than a few issues most of which I have solved.
My question, is there any way to hold a key down (in this case “Left Shift”) while dragging an item? The tutorial basically has an inventory slot, that when dragged and holding Left Shift will split a stack in half. I can share some code if someone is willing to help if needed.
The behavior is basically left clicking and holding the mouse while also holding down the left shift key on an item in a slot-based inventory then dragging the item to another slot on-drop it should split the stack based on a divide by 2 in the code and place half in the new slot and keep the other half in the original slot. Without left shift held it will just move the items to the new slot (moving to new slot works).
Here is the Key Press in my 3rd Person Character
My “On Drag Detected” that looks for the bool “Is Shift Down?”
I can share more if needed such as the Split Item to Index function or the On Drag Over if needed. Appreciate the assistance. I also apologize for the messy blueprints and lack of comments, this is my first real foray into UE.
Quick Update: After adding a breakpoint in the “On Drag Detected” on the Branch just after the "Was Shift Down? bool, it is not detecting the Shift Key as being pressed. I am thinking it may be because I’m using a third person character… not 100% sure. Hope that is enough information to help.
Update I found the issue. It was caused by having the “Input UI Only” set. If I set it to “Game and UI Only” it works. I want to use “UI Only” to prevent the Character movement when the inventory is open. Is there any other way to disable character movement when a UI is active?
After playing around more and more I solved most of my issues. I was using “UI Mode Only” due to prevent some things:
Preventing camera movement (this is now fixed with the set ignore look input).
Preventing the player camera zoom via mouse (this is still an issue due to “Input Game and UI”.
When clicking on the viewport with the inventory widget in focus, causes the “I” (used to open and close inventory) to have to be pressed twice or the inventory widget to be clicked in order to close.
Issues 2 and 3 are still now solved. However, I can use “Input UI Only” to solve them, but then this disables the Shift Key issue from the original post.
Is there a specific reason setting your shift functionality in your character instead detecting it in your widget? For example, there is an “is shift down” blueprint node that you can use: