Skip to content

Commit

Permalink
Merge pull request #162 from Sleitnick/feature/mousemove
Browse files Browse the repository at this point in the history
Mouse moved event
  • Loading branch information
Sleitnick authored Oct 19, 2023
2 parents 38ff0e8 + 16e6b6e commit 0928c46
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions modules/input/Mouse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
-- Stephen Leitnick
-- November 07, 2020

local Trove = require(script.Parent.Parent.Trove)
local Signal = require(script.Parent.Parent.Signal)
local Trove = require(script.Parent.Parent.Trove)

local UserInputService = game:GetService("UserInputService")

Expand Down Expand Up @@ -42,6 +42,14 @@ Mouse.__index = Mouse
@prop RightUp Signal
@tag Event
]=]
--[=[
@within Mouse
@prop Moved Signal<Vector2>
@tag Event
```lua
mouse.Moved:Connect(function(position) ... end)
```
]=]
--[=[
@within Mouse
@prop Scrolled Signal<number>
Expand Down Expand Up @@ -70,6 +78,7 @@ function Mouse.new()
self.RightDown = self._trove:Construct(Signal)
self.RightUp = self._trove:Construct(Signal)
self.Scrolled = self._trove:Construct(Signal)
self.Moved = self._trove:Construct(Signal)

self._trove:Connect(UserInputService.InputBegan, function(input, processed)
if processed then
Expand Down Expand Up @@ -97,7 +106,10 @@ function Mouse.new()
if processed then
return
end
if input.UserInputType == Enum.UserInputType.MouseWheel then
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)
Expand Down
2 changes: 1 addition & 1 deletion modules/input/wally.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "sleitnick/input"
description = "Basic input classes"
version = "2.1.1"
version = "2.2.0"
license = "MIT"
authors = ["Stephen Leitnick"]
registry = "https://github.com/UpliftGames/wally-index"
Expand Down

0 comments on commit 0928c46

Please sign in to comment.