Skip to content

Commit

Permalink
Merge pull request #177 from jisham318/mouse-middle-click
Browse files Browse the repository at this point in the history
Mouse: Middle Button Signals/Method
  • Loading branch information
Sleitnick authored Nov 26, 2023
2 parents 6eb745e + 474a8cc commit 86852cf
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions modules/input/Mouse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ Mouse.__index = Mouse
@prop RightUp Signal
@tag Event
]=]
--[=[
@within Mouse
@prop MiddleDown Signal
@tag Event
]=]
--[=[
@within Mouse
@prop MiddleUp Signal
@tag Event
]=]
--[=[
@within Mouse
@prop Moved Signal<Vector2>
Expand Down Expand Up @@ -77,6 +87,8 @@ function Mouse.new()
self.LeftUp = self._trove:Construct(Signal)
self.RightDown = self._trove:Construct(Signal)
self.RightUp = self._trove:Construct(Signal)
self.MiddleDown = self._trove:Construct(Signal)
self.MiddleUp = self._trove:Construct(Signal)
self.Scrolled = self._trove:Construct(Signal)
self.Moved = self._trove:Construct(Signal)

Expand All @@ -88,6 +100,8 @@ function Mouse.new()
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)

Expand All @@ -99,6 +113,8 @@ function Mouse.new()
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)

Expand Down Expand Up @@ -131,6 +147,13 @@ function Mouse:IsRightDown(): boolean
return UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton2)
end

--[=[
Checks if the middle mouse button is down.
]=]
function Mouse:IsMiddleDown(): boolean
return UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton3)
end

--[=[
Gets the screen position of the mouse.
]=]
Expand Down

0 comments on commit 86852cf

Please sign in to comment.