In the module, there are a few prints commented out (Click, Drag, and two of Release)
Uncomment and see if Release gets printed
Thanks!
In the module, there are a few prints commented out (Click, Drag, and two of Release)
Uncomment and see if Release gets printed
Thanks!
Nope, it doesnāt get printed (also I did uncomment it)
I have to go to work, but when Iām free Iāll look into the issue. Can you DM me your GUI? It might have to do with the layout and parenting.
Oh man, this is humiliating.
The bug was because Iād used autocomplete for a variable and I bumped the wrong one.
Uploaded the updated file. Sorry about that!
Iāve now implemented this into Lua Learning (currently on front page) so Iāll get lots of user feedback and bug reports on it.
I hope it works!
Edit: 4 days later, no complaints so far. It was implemented on almost every ScrollingFrame in the game, so Iām taking this a confirmation of full functionality. Note that I am using the UIS edition, not the CAS. Thereās no camera in my game, so thereās no downside for me. Steps to change your version to the UIS edition can be found below:
I just implemented this into my game and a few players are complaining they canāt scroll?
Iām sorry to hear that!
Without more info, I canāt really help you?
My guess is that youāve hit the ContextActionService sinking issue from earlier in this thread:
To avoid this, youād want to replace the CAS binding with a UserInputService binding that ignores GameProcessed. Note that this means input will not be sunk, and scrolling might affect the camera.
CAS:BindActionAtPriority("SmoothScroll", function(Name,State,Input)
if DraggingBar then return Enum.ContextActionResult.Pass end
local Processed = false
for Frame, Info in pairs(Objects) do
if Info.Hovering and Info.Visibility.Visible == true then
Processed = true
Info.Velocity = Info.Velocity - (Info.Sens * Input.Position.Z * (Info.Inverted and -1 or 1))
end
end
return Processed and Enum.ContextActionResult.Sink or Enum.ContextActionResult.Pass
end, false, 8000, Enum.UserInputType.MouseWheel)
UIS.InputChanged:Connect(function(Input, GP)
if --[[not GP and]] Input.UserInputType == Enum.UserInputType.MouseWheel and not DraggingBar then
for Frame, Info in pairs(Objects) do
if Info.Hovering and Info.Visibility.Visible == true then
Info.Velocity = Info.Velocity - (Info.Sens * Input.Position.Z * (Info.Inverted and -1 or 1))
end
end
end
end)
Yeah I donāt want it to affect the camera
I tried to use it on a scrolling frame with buttons and It didnāt work so I had to disable it for that specific scrolling frame.
The smooth scrolling for the other scrolling frames work fine for me, but a few players sometimes arenāt able to scroll for some reason??
This is awesome! Iāve been using this in all of my ScrollingFrames, it is really smooth.
Iām not sure why but I seem to be receiving an āinvalid frame to smoothā when the frame Iām trying to do is a ScrollingFrame?
Oh nice! Iāve used this quite a bit now and itās pretty good.
Thank you for making this
Roblox has recently released an API for trackpad gestures. As seen previously in this thread, trackpad users can only scroll via the drag bar with this moduleās current state. I am working on adding proper trackpad support, and will then update this thread and the model.
I have a functioning prototype.
However, it falls into the problem of CAS vs. UIS that has been discussed throughout this thread. Because the API is currently UIS-only, there is no way for me to sink the input.
Because of this, this feature may have to wait until Roblox adds trackpad support into the CAS API as well. I have asked them about this, so we shall see.
TL;DR:
Everyone make sure to thank @colbert2677 for he helped me test trackpad support and he solved the UIS/CAS issue.
Previous issues
If you remember earlier in the thread, we discussed these.
If the module uses UIS to scroll, the the scrolling input does not get sunk and will move the camera+any other wheel/pan events youāve connected.
If the module uses CAS to scroll, we can sink the input just fine, but the input doesnāt fire at all when the mouse is over an object inside the frame that can be clicked. (TextBox,ImageButton, etc)
@colbert2677 discovered that the .Active
property fixes the CAS issue, making it the perfect solution. Additionally, the trackpad is an exception to the UIS issue, because the new default camera script uses it too, and only goes if GP is false. The old camera script was CAS-based, so you needed the input sink for it to work. Because the new one is UIS (for trackpads, at least) we can use UIS in this case.
Current behavior
This module now behaves exactly as the default scrolling, but smoothed. It is finally exactly what Iāve been trying to achieve this whole time.
When scrolling, the camera doesnāt get affected. Perfect. When there are GuiButtons in the frame, it still scrolls properly, including sinking the input. We did it!
When you call .Enable()
on a frame, it will disable .Active
on all the frameās descendants (and future descendants), and store what the property was. When you call .Disable()
on the frame, itāll return all the descendants to their original .Active
property. This ensures that CAS behaves properly, and that disabling smoothing will fully return to the original state.
Iām linking it again so you wonāt have to scroll all the way back up.
The sensitivity for trackpads appears to be insane in your Lua Learning game, and frames will scroll a ridiculous amount from a tiny trackpad movement. I am using a trackpad on a MacOS if thatās important. I havenāt yet tried Mac trackpad functionality on a scrolling frame using your module.
Edit: I think this is a bug with your game. The module works fine with my trackpad
Thatās really weird.
And annoying, since I donāt have a trackpad to test with.
Can you DM me more details? Which frame, etc.
I discovered some very bad behavior: when hovering over two ScrollingFrames, both would scroll! This is obviously not ideal, as only the top should scroll.
I started doing a bunch of frustrating ancestry ZIndex tree building and sorting to figure out which is above the other.
Then I found PlayerGui:GetGuiObjectsAtPosition(Mouse.X, Mouse.Y)
. (Wiki)
This function automatically has them sorted, with the top GUI being the first in the array.
Bonus: Itās at mouse position, so I also got to remove all my hovering tracker code since anything in the array is guaranteed to be under the mouse!
(Watch the frame in the background)
(Also, updated OP with example usage on how to automatically smooth every frame with exception support)
Old behavior:
Drag bar jumps to mouse pos, determines canvas position from mouse percent in position, only X or Y bar
(Note how the mouse āslidesā along the bar)
New behavior:
Determines canvas position from mouse delta, allows bar for both directions (but MouseWheel is only for Y in that case
https://www.roblox.com/library/3507192220/SmoothScroll-Module
I forgot that people use folders in their GUIs, so this module would just assume that .Parent
was a GuiBase2d object. It now properly utilizes :FindFirstAncestorWhichIsA()
in order to handle these cases.
However, the drag bar behaves differently on folder-nested frames. I cannot figure out why, since they run the same code. It still works, but it actsā¦ slippery? It doesnāt stick to the mouse properly. Iāll probably facepalm tomorrow and fix it.
https://www.roblox.com/library/3507192220/SmoothScroll-Module
I think Roblox might have changed the .Active
property behavior on Frames because things stopped working for a few people. Fixed it now!
If you called .Disable()
, it didnāt :Destroy()
the scrollbar buttons, leaking Instances. Fixed this too!
(Note that you shouldnāt ever really be calling Disable anyway since it automatically disables upon frame deletion, and toggling back and forth during the game is bad practice and wastes resources)
https://www.roblox.com/library/3507192220/SmoothScroll-Module
For some reason or another, this seems to cause the camera to zoom again; This used to be fixed, correct?