Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Mouse Down and Up events firing even if the UIS processed parameter is true #216

Open
CaptinLetus opened this issue Dec 20, 2024 · 3 comments · May be fixed by #224
Open
Assignees

Comments

@CaptinLetus
Copy link

At the moment, the mouse up and down events do not fire if the UserInputService processed parameter is true

UserInputService:Connect(function (input: InputObject, processed: boolean)
  if processed then return end
end)

My usecase, I am making a custom camera that players can rotate by holding down the right mouse button. If they release the mouse while hovering over a proximity prompt UI, the mouse up event does not fire since processed is true. For this mouse object, I want the events to fire even if processed is true

Perhaps we can add some configuration settings in the mouse constructor to set this as a setting

@hcru77
Copy link

hcru77 commented Jan 29, 2025

I will work on this!

@hcru77
Copy link

hcru77 commented Feb 17, 2025

In the mouse class, you can add the IgnoreProcessedInput setting in the Mouse.luau file in the input folder so that you can set it to true or false whenever you want so that it is customizable for your case. Like the name suggests, it will let you make it so that the mouse button can fire and ignore the processed setting.

self.IgnoreProcessedInput = false 

    self._trove:Connect(UserInputService.InputBegan, function(input, processed)
        if processed and not self.IgnoreProcessedInput then
            return
        end
        if input.UserInputType == Enum.UserInputType.MouseButton1 then
            self.LeftDown:Fire()
        elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
            self.RightDown:Fire()
        elseif input.UserInputType == Enum.UserInputType.MouseButton3 then
            self.MiddleDown:Fire()
        end
    end)

    self._trove:Connect(UserInputService.InputEnded, function(input, processed)
        if processed and not self.IgnoreProcessedInput then
            return
        end
        if input.UserInputType == Enum.UserInputType.MouseButton1 then
            self.LeftUp:Fire()
        elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
            self.RightUp:Fire()
        elseif input.UserInputType == Enum.UserInputType.MouseButton3 then
            self.MiddleUp:Fire()
        end
    end)

    self._trove:Connect(UserInputService.InputChanged, function(input, processed)
        if processed and not self.IgnoreProcessedInput then
            return
        end
        if input.UserInputType == Enum.UserInputType.MouseMovement then
            local position = input.Position
            self.Moved:Fire(Vector2.new(position.X, position.Y))
        elseif input.UserInputType == Enum.UserInputType.MouseWheel then
            self.Scrolled:Fire(input.Position.Z)
        end
    end)

    return self

@Sleitnick Sleitnick self-assigned this Feb 18, 2025
@Sleitnick
Copy link
Owner

@hcru77 It is important for the end-user code to have the processed value to pass on the behavior to the connected code.
@CaptinLetus I agree that this should be changed. Connected user code should be responsible if it wants to deal with whether or not it is processed.

@Sleitnick Sleitnick linked a pull request Feb 18, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants