Hi Guys,
I have another lame newbie question.
I have set up a dialog with an TxtCtrl box and an OK button:
UI = {}
-- create MyDialog
UI.MyDialog = wx.wxDialog (wx.NULL, wx.wxID_ANY, "", wx.wxDefaultPosition, wx.wxDefaultSize, wx.wxDEFAULT_DIALOG_STYLE )
UI.MyDialog:SetSizeHints( wx.wxSize( -1,-1 ), wx.wxSize( -1,-1 ) )
UI.MyDialogSizer = wx.wxBoxSizer( wx.wxVERTICAL )
UI.DataEntry = wx.wxTextCtrl( UI.MyDialog, wx.wxID_ANY, "", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
UI.MyDialogSizer:Add( UI.DataEntry, 0, wx.wxALL, 5 )
UI.m_button9 = wx.wxButton( UI.MyDialog, wx.wxID_ANY, "OK", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
UI.MyDialogSizer:Add( UI.m_button9, 0, wx.wxALL, 5 )
UI.MyDialog:SetSizer( UI.MyDialogSizer )
UI.MyDialog:Layout()
UI.MyDialogSizer:Fit( UI.MyDialog )
UI.MyDialog:Centre( wx.wxBOTH )
-- Connect Events
UI.m_button9:Connect( wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event)
--implements wxID_OK
event:Skip()
return
end )
local rc=UI.MyDialog:ShowModal()
if rc==wx.wxID_OK then wx.wxMessageBox('success') end
if rc==wx.wxID_CANCEL then wx.wxMessageBox('failure')end
Note that I explicitly attached the button which result in:
UI.m_button9:Connect( wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event).
The problem is that when I single step through it all goes swimmingly until I get to the:
local rc=UI.MyDialog:ShowModal() statement. It executes and the dialog pops up, I can enter a string and exit with
a <OK> button click. The code executes the event handler function but at the end of the function re-encounters
the ShowModal() function again and the dialog pops up again in a never ending loop.
As you can see I even tried putting a Return statement in the event handler but it returns straight to the ShowModal() function
again.
I'm struggling with what code needs to go in the handler that allows the handler to execute and then return WITHOUT
executing what amounts to its own calling statement.
I have read the explanation for event:Skip() but am far from sure that I understand its intent.
Craig