@quenty/buttonhighlightmodel 14.10.1-canary.513.484c203.0 → 14.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -6
- package/package.json +10 -11
- package/src/Client/ButtonHighlightModel.lua +2 -69
package/CHANGELOG.md
CHANGED
|
@@ -3,13 +3,9 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
# [14.11.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/buttonhighlightmodel@14.10.0...@quenty/buttonhighlightmodel@14.11.0) (2024-11-03)
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
### Bug Fixes
|
|
10
|
-
|
|
11
|
-
* Include dependency ([5e7a757](https://github.com/Quenty/NevermoreEngine/commit/5e7a7573c5ac93ea0f963b134c65079a30312822))
|
|
12
|
-
* Mouse scrolling scrolling check ([cb322a8](https://github.com/Quenty/NevermoreEngine/commit/cb322a8cd249079890050ac3b520e7024c23e6ca))
|
|
8
|
+
**Note:** Version bump only for package @quenty/buttonhighlightmodel
|
|
13
9
|
|
|
14
10
|
|
|
15
11
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/buttonhighlightmodel",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.11.0",
|
|
4
4
|
"description": "Contains model information for the current button",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -26,18 +26,17 @@
|
|
|
26
26
|
"Quenty"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@quenty/acceltween": "2.5.0",
|
|
30
|
-
"@quenty/baseobject": "10.7.0",
|
|
31
|
-
"@quenty/blend": "12.
|
|
32
|
-
"@quenty/loader": "10.7.0",
|
|
33
|
-
"@quenty/maid": "3.4.0",
|
|
34
|
-
"@quenty/
|
|
35
|
-
"@quenty/
|
|
36
|
-
"@quenty/
|
|
37
|
-
"@quenty/valueobject": "13.10.1-canary.513.484c203.0"
|
|
29
|
+
"@quenty/acceltween": "^2.5.0",
|
|
30
|
+
"@quenty/baseobject": "^10.7.0",
|
|
31
|
+
"@quenty/blend": "^12.11.0",
|
|
32
|
+
"@quenty/loader": "^10.7.0",
|
|
33
|
+
"@quenty/maid": "^3.4.0",
|
|
34
|
+
"@quenty/rx": "^13.11.0",
|
|
35
|
+
"@quenty/steputils": "^3.5.2",
|
|
36
|
+
"@quenty/valueobject": "^13.11.0"
|
|
38
37
|
},
|
|
39
38
|
"publishConfig": {
|
|
40
39
|
"access": "public"
|
|
41
40
|
},
|
|
42
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "a7e6d8dffd16e9b516e352050571009f57fe6c67"
|
|
43
42
|
}
|
|
@@ -42,8 +42,6 @@ local Maid = require("Maid")
|
|
|
42
42
|
local Rx = require("Rx")
|
|
43
43
|
local StepUtils = require("StepUtils")
|
|
44
44
|
local ValueObject = require("ValueObject")
|
|
45
|
-
local RectUtils = require("RectUtils")
|
|
46
|
-
local RxInstanceUtils = require("RxInstanceUtils")
|
|
47
45
|
|
|
48
46
|
local ButtonHighlightModel = setmetatable({}, BaseObject)
|
|
49
47
|
ButtonHighlightModel.ClassName = "ButtonHighlightModel"
|
|
@@ -70,11 +68,6 @@ function ButtonHighlightModel.new(button, onUpdate)
|
|
|
70
68
|
self._isKeyDown = self._maid:Add(ValueObject.new(false, "boolean"))
|
|
71
69
|
self._isHighlighted = self._maid:Add(ValueObject.new(false, "boolean"))
|
|
72
70
|
|
|
73
|
-
-- Mouse state
|
|
74
|
-
self._isMouseOverBasedUponMouseMovement = self._maid:Add(ValueObject.new(false, "boolean"))
|
|
75
|
-
self._isMouseOverScrollingCheck = self._maid:Add(ValueObject.new(false, "boolean"))
|
|
76
|
-
self._lastMousePositionForScrollingCheck = self._maid:Add(ValueObject.new(nil))
|
|
77
|
-
|
|
78
71
|
--[=[
|
|
79
72
|
@prop InteractionEnabledChanged Signal<boolean>
|
|
80
73
|
@readonly
|
|
@@ -160,8 +153,7 @@ function ButtonHighlightModel:SetButton(button: Instance)
|
|
|
160
153
|
if button then
|
|
161
154
|
maid:GiveTask(button.InputEnded:Connect(function(inputObject)
|
|
162
155
|
if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
|
|
163
|
-
self.
|
|
164
|
-
self._isMouseOverBasedUponMouseMovement.Value = false
|
|
156
|
+
self._isMouseOver.Value = false
|
|
165
157
|
end
|
|
166
158
|
|
|
167
159
|
if inputObject.UserInputType == Enum.UserInputType.MouseButton1 then
|
|
@@ -183,9 +175,7 @@ function ButtonHighlightModel:SetButton(button: Instance)
|
|
|
183
175
|
|
|
184
176
|
maid:GiveTask(button.InputBegan:Connect(function(inputObject)
|
|
185
177
|
if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
|
|
186
|
-
self.
|
|
187
|
-
self._isMouseOverScrollingCheck.Value = true
|
|
188
|
-
self._lastMousePositionForScrollingCheck.Value = inputObject.Position
|
|
178
|
+
self._isMouseOver.Value = true
|
|
189
179
|
end
|
|
190
180
|
|
|
191
181
|
if inputObject.UserInputType == Enum.UserInputType.MouseButton1 then
|
|
@@ -196,25 +186,6 @@ function ButtonHighlightModel:SetButton(button: Instance)
|
|
|
196
186
|
self:_trackTouch(inputObject)
|
|
197
187
|
end
|
|
198
188
|
end))
|
|
199
|
-
|
|
200
|
-
-- Track until something indicates removal
|
|
201
|
-
maid:GiveTask(self._isMouseOverBasedUponMouseMovement:ObserveBrio(function(mouseOver)
|
|
202
|
-
return mouseOver
|
|
203
|
-
end):Subscribe(function(brio)
|
|
204
|
-
if brio:IsDead() then
|
|
205
|
-
return
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
self:_trackIfButtonMovedOutFromMouse(brio:ToMaid(), button)
|
|
209
|
-
end))
|
|
210
|
-
|
|
211
|
-
-- We have to track as long as the mouse hasn't moved
|
|
212
|
-
maid:GiveTask(Rx.combineLatest({
|
|
213
|
-
isMouseOverFromInput = self._isMouseOverBasedUponMouseMovement:Observe();
|
|
214
|
-
isMouseOverScrollingCheck = self._isMouseOverScrollingCheck:Observe();
|
|
215
|
-
}):Subscribe(function(state)
|
|
216
|
-
self._isMouseOver.Value = state.isMouseOverFromInput and state.isMouseOverScrollingCheck
|
|
217
|
-
end))
|
|
218
189
|
end
|
|
219
190
|
|
|
220
191
|
self._maid._buttonMaid = maid
|
|
@@ -226,44 +197,6 @@ function ButtonHighlightModel:SetButton(button: Instance)
|
|
|
226
197
|
end
|
|
227
198
|
end
|
|
228
199
|
|
|
229
|
-
function ButtonHighlightModel:_trackIfButtonMovedOutFromMouse(maid, button)
|
|
230
|
-
maid:GiveTask(button.InputChanged:Connect(function(inputObject)
|
|
231
|
-
if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
|
|
232
|
-
self._lastMousePositionForScrollingCheck.Value = inputObject.Position
|
|
233
|
-
end
|
|
234
|
-
end))
|
|
235
|
-
|
|
236
|
-
maid:GiveTask(Rx.combineLatest({
|
|
237
|
-
mousePosition = self._lastMousePositionForScrollingCheck:Observe();
|
|
238
|
-
absolutePosition = RxInstanceUtils.observeProperty(button, "AbsolutePosition");
|
|
239
|
-
absoluteSize = RxInstanceUtils.observeProperty(button, "AbsoluteSize");
|
|
240
|
-
}):Pipe({
|
|
241
|
-
Rx.map(function(state)
|
|
242
|
-
if not state.mousePosition then
|
|
243
|
-
return true
|
|
244
|
-
end
|
|
245
|
-
|
|
246
|
-
local area = Rect.new(state.absolutePosition, state.absolutePosition + state.absoluteSize)
|
|
247
|
-
|
|
248
|
-
if RectUtils.contains(area, Vector2.new(state.mousePosition.x, state.mousePosition.y)) then
|
|
249
|
-
return true
|
|
250
|
-
end
|
|
251
|
-
|
|
252
|
-
-- TODO: check rounded corners and rotated guis
|
|
253
|
-
|
|
254
|
-
return false
|
|
255
|
-
end)
|
|
256
|
-
}):Subscribe(function(state)
|
|
257
|
-
self._isMouseOverScrollingCheck.Value = state
|
|
258
|
-
end))
|
|
259
|
-
|
|
260
|
-
maid:GiveTask(function()
|
|
261
|
-
self._isMouseOverScrollingCheck.Value = false
|
|
262
|
-
self._lastMousePositionForScrollingCheck.Value = nil
|
|
263
|
-
end)
|
|
264
|
-
|
|
265
|
-
end
|
|
266
|
-
|
|
267
200
|
--[=[
|
|
268
201
|
Gets if the button is pressed
|
|
269
202
|
@return boolean
|