I have a chat based application and decided to build the GUI using the
the minimal example found on the wxLua site for my base.

Instead of having everything contained in a single file, I broke it up
into seperate files based on components.
So for instance the frame is in
gui.frame.wx.lua and it's components like the menubar, help menu,
about box etc are all in seperate files.

I then have a single mainapp.wx.lua file that runs a
dofile(filename...) on all of them.
That design works and works well.

Now I needed to add a server connection dialog.
This dialog is comprised of the following.
1 user name field
1 password field
1 button labeled connect

The dialog is access via the file menu, and all is well and good.
The dialog pops up like normal and it's all shiny, until I click the
connect button.
Nothing is happening.

I've even gone so far as to completely gut the connection code. And
replace it with a simple print("Button was clicked!")

Here is the relevant code for the dialog I'm hoping someone can help
me figure out whats wrong with my button

<snip>
--From mainapp.lua
-- Generate a unique new wxEventID
function NEXTEVENT()
    ID_IDCOUNTER = (ID_IDCOUNTER or wx.wxID_HIGHEST) + 1
    return ID_IDCOUNTER
end

-- define custom events here
     EVT_CONNECTION_MENU_SELECTED = NEXTEVENT()
     EVT_BUTTON_CLICK = NEXTEVENT()
</snip>

<snip>
--dlg_server_connect.lua
--This file creates the server connection dialog for the chat application

dlg_server_connect = wx.wxFrame(wx.wxNull,  wx.wxID_ANY,  "Please Log
In") --Create New Dialog/Frame
fld_uname = wx.wxTextCtrl(dlg_server_connect, wx.wxID_ANY, "User
Name"); --User name field
fld_pass =  wx.wxTextCtrl(dlg_server_connect, wx.wxID_ANY,
"Password"); -- password field
btn_connect = wx.wxButton(dlg_server_connect,EVT_BUTTON_CLICK,"Connect!")
--Connect! Button

-- Put the it all in a sizer
local sizerT = wx.wxBoxSizer(wx.wxHORIZONTAL)
sizerT:AddWindow(fld_uname)
sizerT:AddWindow(fld_pass)
sizerT:AddWindow(btn_connect)
dlg_server_connect:SetAutoLayout(true)
dlg_server_connect:SetSizer(sizerT)

dlg_server_connect:Connect(EVT_BUTTON_CLICK,
                                            function (event)
                                                    print("You clicked
a button, woohoo!")

frame:SetStatusText("Connect was Clicked")

dlg_server_connect:Close(true)
                                            end) --Connect the event Handler
</snip>

Now at least to me it looks like I've done everything normally
First I reserve a new event ID,

Next I create a new frame, then I create 2 text fields and a button, I
register the button to throw the eventID, then I place all components
except the frame in a sizer.

I add the sizer to the frame

And I tell the frame to listen for the button to click, at which time
it calls the anonymous function.

Am I missing something here?

Anyways I'm completely lost as to why this isn't working, any help is
greatly appreciated!

Regards,

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to