diff --git a/samples/SettingsMenu/init.luau b/samples/SettingsMenu/init.luau index 2c16ba0..db6113e 100644 --- a/samples/SettingsMenu/init.luau +++ b/samples/SettingsMenu/init.luau @@ -5,7 +5,6 @@ local Themer = OnyxUI.Themer local Util = OnyxUI.Util local Children = Fusion.Children local InnerScope = Fusion.innerScope -local Components = OnyxUI.Components local SettingToggle = require(script.SettingToggle) @@ -14,7 +13,7 @@ export type Props = { } return function(Scope: Fusion.Scope, Props: Props) - local Scope = InnerScope(Scope, Fusion, Util, Components, { + local Scope = InnerScope(Scope, Fusion, OnyxUI.Util, OnyxUI.Components, { SettingToggle = SettingToggle, }) local Theme = Themer.Theme:now() @@ -69,6 +68,7 @@ return function(Scope: Fusion.Scope, Props: Props) Scope:TextInput { AutomaticSize = Enum.AutomaticSize.Y, PlaceholderText = "Nickname", + CharacterLimit = 20, }, }, }, diff --git a/src/Components/TextInput.luau b/src/Components/TextInput.luau index 0b71a47..24c0b2c 100644 --- a/src/Components/TextInput.luau +++ b/src/Components/TextInput.luau @@ -13,7 +13,6 @@ local Themer = require(OnyxUI.Themer) local Peek = Fusion.peek local OnEvent = Fusion.OnEvent -local Out = Fusion.Out local InnerScope = Fusion.innerScope local Base = require(script.Parent.Base) @@ -124,16 +123,16 @@ return function(Scope: Fusion.Scope, Props: Props) end) ) - local OutText = Scope:Value("") - local ProcessedText = Scope:Computed(function(Use) - local OutTextValue = Use(OutText) or "" - local CharacterLimitValue = Use(CharacterLimit) - local LimitedText = OutTextValue:sub(1, utf8.offset(OutTextValue, CharacterLimitValue)) - local FullyProcessedText = Use(TextProcessor)(LimitedText) + local InvalidInputActive = Scope:Value(false) + + local function ProcessText(NewText: string) + local CharacterLimitValue = Peek(CharacterLimit) + local TextProcessorValue = Peek(TextProcessor) + local LimitedText = NewText:sub(1, utf8.offset(NewText, CharacterLimitValue)) + local FullyProcessedText = TextProcessorValue(LimitedText) return FullyProcessedText - end) - local InvalidInputActive = Scope:Value(false) + end local Object = Scope:Hydrate(Scope:Base(Util.CombineProps(Props, { ClassName = "TextBox", @@ -246,22 +245,26 @@ return function(Scope: Fusion.Scope, Props: Props) SoundService:PlayLocalSound(Peek(Theme.Sound.Hover)) end end, - [Out "Text"] = OutText, } - Scope:Observer(OutText):onChange(function() - local ProcessedTextValue = Peek(ProcessedText) - local OutTextValue = Peek(OutText) + table.insert( + Scope, + Object:GetPropertyChangedSignal("Text"):Connect(function() + local NewText = Object.Text + local ProcessedText = ProcessText(NewText) - Text:set(ProcessedTextValue) - Object.Text = ProcessedTextValue + if Object.Text ~= ProcessedText then + Text:set(ProcessedText) + Object.Text = ProcessedText + end - if utf8.len(OutTextValue) ~= utf8.len(ProcessedTextValue) then - InvalidInputActive:set(true) - task.wait(0.075) - InvalidInputActive:set(false) - end - end) + if utf8.len(NewText) ~= utf8.len(ProcessedText) then + InvalidInputActive:set(true) + task.wait(0.075) + InvalidInputActive:set(false) + end + end) + ) return Object end diff --git a/src/Themer/NewTheme.luau b/src/Themer/NewTheme.luau index 65f9e2f..83fdc85 100644 --- a/src/Themer/NewTheme.luau +++ b/src/Themer/NewTheme.luau @@ -217,7 +217,7 @@ local function NewTheme(Scope: Fusion.Scope, ThemeSpec: ThemeSpec) Immediate = Scope:Value(1000), }, SpringDampening = { - Base = Scope:Value(40), + Base = Scope:Value(1), ["0.1"] = Scope:Value(nil), ["0.175"] = Scope:Value(nil), ["0.25"] = Scope:Value(nil),