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

Mouse moved event #162

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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