Re: [wxlua-users] Event handling function inside a module

2012-02-16 Thread John Labenski
>> On Thu, Feb 16, 2012 at 12:06 PM, Mike Richards >>> >>> function test() is declared in the current scope, and globally as >>> filterform.test >>> >>> After fiddling around for a bit, it looks like wx.wxEvtHandler:Connect >>> saves upvalues, but not the current function environment (scope), whic

Re: [wxlua-users] Event handling function inside a module

2012-02-16 Thread Milind Gupta
Thanks, Milind On Thu, Feb 16, 2012 at 1:53 PM, Mike Richards wrote: > Milind, > You could also accomplish the same with a little less typing if you want: > > module(...) > local _M = _M -- save the module table > > then in your event handler function it's just setfenv(1, _M) > > Mike > > On 2/

Re: [wxlua-users] Event handling function inside a module

2012-02-16 Thread Mike Richards
Milind, You could also accomplish the same with a little less typing if you want: module(...) local _M = _M -- save the module table then in your event handler function it's just setfenv(1, _M) Mike On 2/16/2012 4:42 PM, Milind Gupta wrote: Hi Mike, I agree a good practice is to declar

Re: [wxlua-users] Event handling function inside a module

2012-02-16 Thread Milind Gupta
Hi Mike, I agree a good practice is to declare things local, only for things we want to access from outside unrestricted its easier not to declare them local. So anyway what I ended up doing is having the first statement in my event handler function as setfenv(1,package.loaded[modname]) wher

Re: [wxlua-users] Event handling function inside a module

2012-02-16 Thread Mike Richards
John and Milind, function test() is declared in the current scope, and globally as filterform.test After fiddling around for a bit, it looks like wx.wxEvtHandler:Connect saves upvalues, but not the current function environment (scope), which was set in the call to module(...) When the event

Re: [wxlua-users] Event handling function inside a module

2012-02-16 Thread Milind Gupta
Hello John, Sorry for the carelessness. Here is a full set with minimal.lua which is the main file to run and the module function is called by the Help->About call back. That is true making test a local function makes it work although I am not totally clear why but if you press the other

Re: [wxlua-users] Event handling function inside a module

2012-02-15 Thread John Labenski
On Wed, Feb 15, 2012 at 3:14 AM, Milind Gupta wrote: > Hello John, > > thanks for the reply. Here is an example code that does not work Please try to provide enough code to make it run out of the box... I had to add back GUI.initFrameH and rem out the usage of MainSizer to make it even

Re: [wxlua-users] Event handling function inside a module

2012-02-15 Thread Milind Gupta
Hello John, thanks for the reply. Here is an example code that does not work (Pasted below and attached the file as well). A function from the main wxlua application calls filterFormActivate which sets up a simple frame with 2 buttons and one static text and associates the button click t

Re: [wxlua-users] Event handling function inside a module

2012-02-14 Thread John Labenski
On Tue, Feb 14, 2012 at 10:09 PM, Milind Gupta wrote: > Hi, >        I wonder if this is a known issue or something intentional. I have > made a module that creates a frame with some buttons and associates an event > handling function for the button click, the function resides in the module > itse

[wxlua-users] Event handling function inside a module

2012-02-14 Thread Milind Gupta
Hi, I wonder if this is a known issue or something intentional. I have made a module that creates a frame with some buttons and associates an event handling function for the button click, the function resides in the module itself. The frame also is visible in the module. Now when the event h