function methods.DoLockChatBar(J)if J.TextLabel then if LocalPlayer.UserId>0 then J.TextLabel.Text="\084\111 \099\104\097\116 \105\110 \103\097\109\101\044 \116\117\114\110 \111\110 \099\104\097\116 \105\110 \121\111\117\114 \080\114\105\118\097\099\121 \083\101\116\116\105\110\103\115\046"else J.TextLabel.Text="\083\105\103\110 \117\112 \116\111 \099\104\097\116 \105\110 \103\097\109\101\046"end J:CalculateSize()end if J.TextBox then J.TextBox.Active=false J.TextBox.Focused:connect(function()J.TextBox:ReleaseFocus()end)end end function methods.SetUpTextBoxEvents(P,J,p,w)UserInputService.InputBegan:connect(function(p,w)if p.KeyCode==Enum.KeyCode.Backspace then if P:IsFocused()and J.Text==""then P:SetChannelTarget(ChatSettings.GeneralChannelName)end end end)J.Changed:connect(function(p)if p=="\065\098\115\111\108\117\116\101\083\105\122\101"then P:CalculateSize()return end if p~="\084\101\120\116"then return end P:CalculateSize()if string.len(J.Text)>ChatSettings.MaximumMessageLength then J.Text=string.sub(J.Text,1,ChatSettings.MaximumMessageLength)return end if not P.InCustomState then local p=P.CommandProcessor:ProcessInProgressChatMessage(J.Text,P.ChatWindow,P)if p then P.InCustomState=true P.CustomState=p end else P.CustomState:TextUpdated()end end)local function W(w)if w or J.Text~=""then p.Visible=false else p.Visible=true end end w.MouseButton1Click:connect(function()if w.Text~=""then P:SetChannelTarget(ChatSettings.GeneralChannelName)end end)J.Focused:connect(function()if not P.UserHasChatOff then P:CalculateSize()W(true)end end)J.FocusLost:connect(function(p,w)P:CalculateSize()if w and w.KeyCode==Enum.KeyCode.Escape then J.Text=""end W(false)end)end function methods.GetTextBox(J)return J.TextBox end function methods.GetMessageModeTextButton(J)return J.GuiObjects.MessageModeTextButton end
-- Used to lock the chat bar when the user has chat turned off.
function methods:DoLockChatBar()
	if self.TextLabel then
		if LocalPlayer.UserId > 0 then
			self.TextLabel.Text = "To chat in game, turn on chat in your Privacy Settings."
		else
			self.TextLabel.Text = "Sign up to chat in game."
		end
		self:CalculateSize()
	end
	if self.TextBox then
		self.TextBox.Active = false
		self.TextBox.Focused:connect(function()
			self.TextBox:ReleaseFocus()
		end)
	end
end

function methods:SetUpTextBoxEvents(TextBox, TextLabel, MessageModeTextButton)
	--// Code for getting back into general channel from other target channel when pressing backspace.
	UserInputService.InputBegan:connect(function(inputObj, gpe)
		if inputObj.KeyCode == Enum.KeyCode.Backspace then
			if self:IsFocused() and TextBox.Text == "" then
				self:SetChannelTarget(ChatSettings.GeneralChannelName)
			end
		end
	end)

	TextBox.Changed:connect(function(prop)
		if prop == "AbsoluteSize" then
			self:CalculateSize()
			return
		end

		if prop ~= "Text" then
			return
		end

		self:CalculateSize()

		if string.len(TextBox.Text) > ChatSettings.MaximumMessageLength then
			TextBox.Text = string.sub(TextBox.Text, 1, ChatSettings.MaximumMessageLength)
			return
		end

		if not self.InCustomState then
			local customState = self.CommandProcessor:ProcessInProgressChatMessage(TextBox.Text, self.ChatWindow, self)
			if customState then
				self.InCustomState = true
				self.CustomState = customState
			end
		else
			self.CustomState:TextUpdated()
		end
	end)

	local function UpdateOnFocusStatusChanged(isFocused)
		if isFocused or TextBox.Text ~= "" then
			TextLabel.Visible = false
		else
			TextLabel.Visible = true
		end
	end

	MessageModeTextButton.MouseButton1Click:connect(function()
		if MessageModeTextButton.Text ~= "" then
			self:SetChannelTarget(ChatSettings.GeneralChannelName)
		end
	end)

	TextBox.Focused:connect(function()
		if not self.UserHasChatOff then
			self:CalculateSize()
			UpdateOnFocusStatusChanged(true)
		end
	end)

	TextBox.FocusLost:connect(function(enterPressed, inputObject)
		self:CalculateSize()
		if inputObject and inputObject.KeyCode == Enum.KeyCode.Escape then
			TextBox.Text = ""
		end
		UpdateOnFocusStatusChanged(false)
	end)
end

function methods:GetTextBox()
	return self.TextBox
end

function methods:GetMessageModeTextButton()
	return self.GuiObjects.MessageModeTextButton
end
