0 Members and 2 Guests are viewing this topic.
local t = 0function on.paint(gc) gc:drawString("Times that focus got lost: " .. t, 10, 10, "top")endfunction on.loseFocus() t=t+1end
Is the order of entered code (I am a newbie in Lua generally) important, too (e.g. of class definitions, variable definitions, event handlers)?
InputField = class() -- a class I use to enter input variablesfunction InputField:init(name,x,y,init_value) self.name = name self.x = x self.y = y self.editor = D2Editor.newRichText() self.editor:move(x+30,y) self.editor:resize(100,28) self.editor:setBorder(1) self.editor:setText(var.recall(name) or (init_value or 0)) -- initially store at construction time: init_value (if defined) or 0 (if not defined) or already stored variable value (if the page is re-entered) var.store(name,self.editor:getText())end...function InputField:storeVariable() -- called by clients like on.loseFocus() function var.store(self.name,self.editor:getText())end...function on.construction() -- create "objects" ... field = {} field[1] = InputField('er',2,4) field[2] = InputField('ev',2,34) ...endfunction on.getFocus() field[1]:setFocus()endfunction on.loseFocus() for i = 1, #field do field:storeVariable() endend
self.editor:registerFilter{loseFocus=function () self:storeVariable() end}
Actually, the utmost important thing here is to fully understand the bits and bolts of TI/Lua specific event mechanism,(what/when/why triggers), which gives you then the real power in designing apps.Where can one find an additional/complete documentation on that subject?
I am a newbie regarding TI-Nspire Lua programming (got my CX CAS this week, immediately updated to OS v3.2).
Hello guys,you gave me a nice "homework" to do now I'll enjoy study it (which will take some time).Thanks and best regards,Goran