BindAction Mouse click is not working over buttons

Reproduction Steps

  1. Create a button
  2. Run this on LocalScript:
local ContextActionService = game:GetService("ContextActionService")

local function Click(actionName, inputState, inputObj)
	print("actionName, inputState, inputObj: ", actionName, inputState, inputObj.UserInputType)
end

ContextActionService:BindAction("Click", Click, false, Enum.UserInputType.MouseButton1)
  1. Click in and out of the button

Expected Behavior
function Click should be fired on any situation

Actual Behavior
function Click is not being fired when clicking a button

Issue Area: Engine
Issue Type: Other
Impact: High
Frequency: Constantly

2 Likes

Isn’t this expected behaviour since most of the time, we don’t want click operations to fire when we click a button such a ‘buy’ etc.

This doesn’t seem like it should have high impact.

3 Likes

It’s not entirely true. A function cannot be defined by something like “most of the time”. Either it is or it isn’t.
UserInputService.InputBegan is activated even when a button is clicked. ContextActionService:BindAction should do the same. Or, if not, there should be a good explanation for this, and more importantly, this limitation should be documented, which doesn’t happen in both cases.
So, once again, let’s let Roblox judge this.

1 Like

ContextActionService is used for, as the name implies, react to inputs depending on the context of the action. Clicking freely not on a button is obviously a different context than clicking on one, if you want the “always” behavior I recommend using what you yourself already mentioned:

2 Likes

Printing out the mouse input as a string from UserInputService.InputBegan will only print out “Unknown”. This includes right mouse clicks, which means you can’t differentiate between mouse 1 or mouse 2 inputs. I recommend using Mouse.Button1Down / Mouse.Button2Down instead

As people stated above, this is not a bug.

1 Like