Q:
I've a form, with a new container, with a button.
On the "cick" event, I call a procedure "sp_close_handler"
Code:
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?
for example:
Code:
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.. :-)
A:
Lianja objects are dynamically extensible so you can define your own properties on the command button,
Code:
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.
Code:
mydataobj = object()
mydataobj.hello = "world"
sp_close.mydata = mydataobj
or
Code:
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.
Code:
sp_close.mydata.hello
etc.
and as it turns out you can attach arrays to UI objects also, and arrays can contain objects or other arrays...
Code:
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.
All topics in [Answers] alphabetically: https://www.lianja.com/community/sho...ll=1#post13748
These answers are also systematized on the site "Lianja developer": https://lianjadeveloper.wordpress.co...ory/procedure/
Bookmarks