Jump to content

how to overwrite TextEdit:OnTextInput(text)


rexih

Recommended Posts

i want to close the check for valid characters, 

here is the orginal code:

function TextEdit:OnTextInput(text)	if not self.editing then return end	if not self.shown then return end	if self.limit then		local str = self:GetString()		--print("len", string.len(str), "limit", self.limit)		if string.len(str) >= self.limit then			return		end	end	if self.validchars then		if not string.find(self.validchars, text, 1, true) then			return		end	end		self.inst.TextEditWidget:OnTextInput(text)end

and i use AddClassPostConstruct to do it,but i turns out wrong

AddClassPostConstruct("widgets/textedit", function(self,...)	if not self.OnTextInput then return end	--self.OnTextInput(...)	self.OldOnTextInput=self.OnTextInput	local function NewOnTextInput(self,text)		self.OldOnTextInput(text)			if not self.editing then return end		if not self.shown then return end		if self.limit then			local str = self:GetString()			--print("len", string.len(str), "limit", self.limit)			if string.len(str) >= self.limit then				return			end		end		--to comment		-- if self.validchars then			-- if not string.find(self.validchars, text, 1, true) then				-- return			-- end		-- end			self.inst.TextEditWidget:OnTextInput(text)		end	self.OnTextInput=NewOnTextInputend)

so ,so coule anyone help me 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...