36
« on: January 29, 2019, 05:21:20 AM »
You dont have to use a button click event to initiate wx.wxID_OK, within wxFB change the id of the button from wx.wxID_ANY to wx.wxID_OK and it will automatically quit the dialog for you and return the appropiate msg, also if you add a close event to the dialog as well as a cancel button you can have this return the wx.ID_CANCEL using the EndModal method and passing back wx.ID_CANCEL this should be the default return for the close but for some reason wxlUA passes back wx.wxID_OK instead??.
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_OK, "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 )
UI.MyDialog:Connect( wx.wxEVT_CLOSE_WINDOW, function(event)
UI.MyDialog:EndModal(wx.wxID_CANCEL) --End the dialog and pass back wxID_CANCEL
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
DazTheGas