Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: KentCNC on March 28, 2021, 01:58:04 PM
-
Another seemingly simple issue that I can't figure out after searching for a couple hours. In Lua, I want to create a modal dialog box with OK and Cancel buttons. I assume I can then use the return value in an IF statement afterward. It seems I could use a wxMessageDialog with wxOK and wxCancel buttons. I just can't find a good example or description of how you do this.
-
Well, it is not as simple as it would first seem unless you know wxLua like the back of your hand. I would use wxFormBuilder to create the dialog and paste it into your code. Use a wxDialog as your base and make the buttons call EndModal(myReturnCode) where myReturnCode is what you want the modal dialog to return. It could be some stock value like wx.wxID_OK or wx.wxID_CANCEL, or some custom value you create.
Do a search on wxFormBuilder in this forum and read up on it.
Steve
-
Thank you for the response. I'll have to see if I can get creative and work around the need for a dialog box. If not, guess I'll need to learn more.
Thanks Again!
-
Hi,
of all of the features of Lua I find wx.Lua the hardest to get my head around.
There is very good reference material, for geeks, by geeks and in geekese!
I found the first few faltering steps were when I copied and pasted some of the dialogues in LuaExamples. In particular I found
the file dialogue useful. I experimented with it until understood each of the parameters and their syntax. It was slow but I got several
very useful macros which I now use daily.
At smurphs suggestion I did experiment with wxFormBuilder. I have spent about six hours on it so far, but probably need to spend
a lot more to become familiar with it. The adavantage is that you can see wxWidget code, which in conjunction with the reference material,
you can start to de-mystify it all.
raig
-
If your OK and CANCEL buttons can be YES and NO instead, you could use something like this...
local response = wx.wxMessageBox("Message", "Title", wx.wxYES_NO)
if (response == 2) then
-- user said YES
else
-- user said NO
end