--Hide cmdbar and request command when FocusLost

local function setupEnterPress(props)
	props.textBox.FocusLost:connect(function(enter)
		if props.mainParent.Name ~= "CmdBar" or props.specificArg then
			if props.suggestionDisplayed > 0 then
				selectSuggestion(props, props.specificArg)
			end
		else
			if props.suggestionDisplayed > 0 and not forceExecute and main.device ~= "Mobile" then
				selectSuggestion(props)
			elseif enter then
				if forceExecute then
					selectSuggestion(props)
					--wait()
				end
				module:CloseCmdBar()
				if #props.textBox.Text > 1 then
					local commandToRequest = props.textBox.Text
					local firstChar = string.sub(commandToRequest,1,1)
					if firstChar ~= main.settings.UniversalPrefix and firstChar ~= main.pdata.Prefix then
						commandToRequest = main.pdata.Prefix..commandToRequest
					end
					local endChar = string.sub(commandToRequest,-1)
					if endChar == " " then
						commandToRequest = string.sub(commandToRequest,1,-1)
					end
					main.signals.RequestCommand:InvokeServer(commandToRequest)
				end
			end
		end
	end)
end
