Hi Luciano,

  Sorry, but I don't know how to answer that question. I guess it depends a lot 
on each developer style and needs.

  I've seen so different structures around here that I cannot say which one is 
the most common. :)

  And in fact that remotes to "what's the most common structure for a Lua 
application?"

Best,
Scuri

> -----Original Message-----
> From: luciano de souza [mailto:[email protected]]
> Sent: terça-feira, 5 de junho de 2012 17:13
> To: [email protected]
> Subject: Re: [Iup-users] Attaching an action to a button without a closure
> 
> Antônio,
> 
> I add a question. I tried to avoid closures, but what  is I tried to avoid 
> precisely
> the recommended procedure? If I use button1:action, then I can imagine only
> two situations: or I use closure or IUP controls were declared as a public
> variables.
> For this reason, I redo my question: what's the best structure for a IUP
> program? If it's not possible to say what's the best, then, what's the most
> common structure for a IUP program?
> 
> 
> 2012/6/5, luciano de souza <[email protected]>:
> > Hello all,
> >
> > When attatching a function to a button event, I can use
> > button1:action(). However, in certain circunstances, it's not  good to
> > do it. See the code bellow:
> >
> > require('iuplua')
> >
> > function main(title)
> > local button1, vbox
> >
> > button1 = iup.button{title = 'Botão 1'} vbox = iup.vbox{button1}
> > return iup.dialog{vbox; title = title} end
> >
> > function button1_action()
> > iup.Message('Aviso', 'O botão 1 foi pressionado') end
> >
> > dlg = main('Teste')
> > dlg:show()
> > iup.MainLoop()
> >
> > If I use button1:action, it was necessary to place it inside main
> > whereas I want to place it outside.
> >
> > How to link button1 to the button1_action(?
> >
> > One hypothesis could be:
> >
> > button1 = iup.button{title = 'Botão 1', action = function () return
> > button1_action()  end}
> >
> > It works, but this choice is low readable. I tried:
> >
> > function main(title)
> > local button1, vbox
> >
> > button1 = iup.button{title = 'Botão 1'} iup.SetAttribute(button1,
> > 'ACTION', 'button1_action') vbox = iup.vbox{button1} return
> > iup.dialog{vbox; title = title} end Actually, I want to use
> > iup.SetAttribute to link events. I could place my callback without
> > closures and without action = function()..
> >
> > Why didn't iup.SetAttribute work?
> >
> > Regards,
> >
> > Luciano
> >
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and threat
> landscape has changed and how IT managers can respond. Discussions will
> include endpoint security, mobile security and the latest in malware threats.
> http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Iup-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/iup-users


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to