I’ve a form, with a new container, with a button.
On the “cick” event, I call a procedure “sp_close_handler”
oContBottom.addObject("sp_close", "commandbutton") sp_close.move(1, 1, 60, 20) sp_close.text = "Close" sp_close.click = sp_close_handler
proc sp_close_handler() p_myform.close() endproc
can I send a parameter on the call?
oContBottom.addObject("sp_close", "commandbutton") sp_close.move(1, 1, 60, 20) sp_close.text = "Close" sp_close.click = sp_close_handler with "aaa"
proc sp_close_handler(m_text) lianja.showmessage(m_text) p_myform.close() endproc
naturally, this code not work.. 🙂
Lianja objects are dynamically extensible so you can define your own properties on the command button,
sp_close.myvar = "something"
then in the sp_close_handler() just reference this.myvar.
Note that in Lianja 3.4 you can associate objects with UI components too.
mydataobj = object() mydataobj.hello = "world" sp_close.mydata = mydataobj
sp_close.mydata = object() sp_close.mydata.hello = "world"
Notice how objects are dynamically extensible.
then later you can reference the members of objects like this.
and as it turns out you can attach arrays to UI objects also, and arrays can contain objects or other arrays…
declare myarray[10,10] myarray[1,1] = "hello" btn.myarray = myarray ? btn.myarray[1,1] ? btn.myarray
So this allows you to attach business objects to UI controls as all objects and arrays in Lianja are reference counted so going out of scope does not affect them.
So with some creative thinking you can save and restore business objects and attach them to the UI controls of your apps in the “ready” delegate.