[SOLVED] "Input key selector" does not take the mouse wheel

Good day’s time!

Let me describe a problem: I’ve created a “Menu” widget, which has an ability to bind buttons for action or axis; I use an “Input key selector” for this, which is situated inside the “Scroll box”. And all things would be nice, except one: an “Input key selector” doesn’t want to receive neither “Mouse Wheel Up”, nor “Mouse Wheel Down” as a button’s bindings. What can it suppose to be? Is it a bug, or is it just me? Do I need to solve this problem by myself, or it’s an UE4.18.3 issue, and all I need - is to update it to more fresh version?

P.S.: Trying to do this with the Blueprint system.

UPDATE:

Still an issue in UE4.22.3.

Thank you!

Still an issue in 4.22.

Input Key Selector completely ignores Mouse Wheel Up/Down actions.

Gratch, seems to me, you misunderstood the situation. I didn’t tell that mouse input not working, I tell that “Input key selector” cannot receive any of “Up/Down” bindings. Read carefully, give me a favour.
However, if you think that I’m wrong, so, please, bring here your BP example.

I misunderstood. I looked into it. You’re right. Input Key Selector does not respond to mouse wheel input. Odd. Must be an oversight. I borrowed some code from [Mathew Wadstein][1] and came up with a work-around. It’s based on the idea that we’re not going to be using all our keys in-game. So, pick two unused keys and remap (intercept) them to your mouse wheel buttons during the OnSelectKey event.

285916-renameinputkeyselector.jpg

I misunderstood the question, originally. I looked into it. You’re right. Input Key Selector does not respond to mouse wheel input. Odd. Must be an oversight. I borrowed some code from [Mathew Wadstein][1] and came up with a work-around. It’s based on the idea that we’re not going to be using all our keys in-game. So, pick two unused keys and remap (intercept) them to your mouse wheel buttons during the OnSelectKey event.

Mouse wheel key binding is working in 4.22.1. If it’s not working in your project, then you have to hunt down every single one of its event calls. As far as I know, it can only be used once. The first blueprint that calls a mouse wheel event will consume it, and it will not work anywhere else. Choose the placement of your ONE mouse wheel call wisely. I suggest placing it in either your character’s blueprint or its controller. Then, from there, you can add an event dispatch that’s triggered by the mouse wheel event. Next, go to any other blueprint needing a mouse wheel event. From there, cast back to your char’s bp (preferably on event-begin-play), and bind its event dispatch to the this other bp’s triggering event which requires the mouse wheel input.

Yes, I’ve already saw a Wadstein’s videos, and this video wasn’t an exception. The problem in this case is that you hard-coded a “Mouse Wheel”, but this is not a solution; the “seed of evil” is when you try to bind a MW via widget interface, an “Input Key Selector” will completely ignore all your attempts to do it.
This bug(?) does a really headache for mass of people, unfortunately. And neither me, nor anybody propose an universal solution, as far as I know.

Finally, I’ve found out, how to do it via BP only! It’s not so easy, but it works now, so IKS gets and sets Mouse Wheels very well without any problems. Problem solved.

Please post a screenshot of your BP solution.

Would you mind explaining how you solved this?

I disagree. The mouse wheel is not “hard-coded.” It’s bound to two unused keys * and - on the numpad in this case, but you can use whatever unused keys you want. Just pick them from the drop-down menu at the “Make InputActionKeyMapping” node. You would also have to inform the user of these keys. Then, when you press the * key from within the HUD in-game the InputKeySelector will see it as the MouseWheelUp key and bind it accordingly. Here, I bound it to Jump, so when I hit MouseWheelUp, my character jumps. But, you could bind it to whatever you want. Just make sure to rename the InputKeySelector to the corresponding action (jump, attack, walk, sprint, whatever), because the script takes that name and matches it with the ActionMappings in your project settings.

Wow, the syntax and features on this website are driving me f-ing nuts. I can’t edit posts and I can’t delete them, and now I realize how bad a choice the “*” was for this example. It’s the multiplication sign from the numpad. That’s what I bound MouseWheelUp to.

Why are you use even bothering to post if you’re not going to provide an answer?

3 Likes

So was anyone able to find a solution for this? I need a way for the Input Key Selector to detect axis events on the mouse or on the gamepad but it is not working. Currently using 5.2.1, any help is greatly appreciated!

Also seeing this issue. Pretty bad one.

For those willing to modify the engine, you can avoid awkward Blueprint workarounds by modifying two files and solving it the “right” way. It was relatively straightforward to figure out how to do this since similar functions already existed, so my guess is this is indeed an oversight by Epic and I’m not sure how it hasn’t been patched yet (surely they ran into it themselves in their own games?)

The solution:

Put this:

SLATE_API virtual FReply OnMouseWheel(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;

…into SInputKeySelector.h inside the SInputKeySelector class, preferably next to the other ‘OnKeyDown’ esque functions. Then, in SInputKeySelector.cpp:

FReply SInputKeySelector::OnMouseWheel(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
FKey MouseWheelKey = MouseEvent.GetWheelDelta() > 0 ? FKey(EKeys::MouseScrollUp) : FKey(EKeys::MouseScrollDown);
EModifierKey::Type ModifierKey = EModifierKey::FromBools(
MouseEvent.IsControlDown() && MouseWheelKey != EKeys::LeftControl && MouseWheelKey != EKeys::RightControl,
MouseEvent.IsAltDown() && MouseWheelKey != EKeys::LeftAlt && MouseWheelKey != EKeys::RightAlt,
MouseEvent.IsShiftDown() && MouseWheelKey != EKeys::LeftShift && MouseWheelKey != EKeys::RightShift,
MouseEvent.IsCommandDown() && MouseWheelKey != EKeys::LeftCommand && MouseWheelKey != EKeys::RightCommand );

// Don’t allow chords consisting of just modifier keys.
if ( bIsSelectingKey && (bAllowGamepadKeys || MouseWheelKey.IsGamepadKey() == false) && ( MouseWheelKey.IsModifierKey() == false || ModifierKey == EModifierKey::None ) )
{
SetIsSelectingKey( false );

  if (bEscapeCancelsSelection && (MouseWheelKey == EKeys::Escape || IsEscapeKey(MouseWheelKey)))
  {
  	return FReply::Handled();
  }

  SelectKey(
  	MouseWheelKey,
  	ModifierKey == EModifierKey::Shift,
  	ModifierKey == EModifierKey::Control,
  	ModifierKey == EModifierKey::Alt,
  	ModifierKey == EModifierKey::Command);
  return FReply::Handled();

}
else if (!bIsSelectingKey && Button.IsValid())
{
return Button->OnMouseWheel(MyGeometry, MouseEvent);
}

return SCompoundWidget::OnMouseWheel(MyGeometry, MouseEvent);
}

I just tested it now and it seems to work fine, I may have overlooked some details but it gets the job done

In case someone else is looking for a BP only solution (can be done in C++ as well, without engine modification). I found a solution based on @Vioxtar 's approach:

We have the InputKeySelector within a UserWidget wrapper (for stuff like showing a nice icon instead if the text would be too long, like e.g. “left mouse button”) and in this BP I simply overrode the OnMouseWheel event.

  • In that handler you first want to make sure the InputKeySelector is selecting (else return unhandled) to not meddle with scrolling accidentally
  • Then set the selected key to either MouseWheelUp or MouseWheelDown based on the wheel delta of the mouse event
  • Then you need to steal the focus from the InputKeySelector. We simply do this by focusing the wrapping widget. This is one of the very few ways to force the InputKeySelector to stop selecting from the outside! (otherwise this can only be done from within the underlying slate widget)
  • Lastly return handled to consume the scroll event and you’re done

Blueprint: Mouse wheel scrolling for InputKeySelector posted by anonymous | blueprintUE | PasteBin For Unreal Engine