Untested example code; Let's call it "TextBox"
Code: Select all
LoveUI.require("LoveUIControl.lua")
LoveUI.require("LoveUITextfieldCell.lua")
LoveUI.require("LoveUITextfield.lua")
TextBox=LoveUI.Textfield:new()
function TextBox:init(frame)
LoveUI.Textfield.init(self, frame) -- must init super class!
self.cell.value="MY CUSTOM VALUE";
return self
end
function Textbox:becomeFirstResponder()
LoveUI.Textfield.becomeFirstResponder(self) -- for super class
self.cell.value = ""; -- clear it on focus.
end
Code: Select all
TextBox:new(myframe)
aView:addSubview(TextBox)
TextfieldCell handles more complicated behaviours of the textfield like selection and moving cursors; simple stuff is implemented inside the textfield itself.