Hello Guest it is November 27, 2021, 05:41:40 AM

Author Topic: How to Create a Simple Dialog Box  (Read 403 times)

0 Members and 1 Guest are viewing this topic.

How to Create a Simple Dialog Box
« 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.

Offline smurph

  • *
  •  1,475 1,475
  • "That there... that's an RV."
    • View Profile
Re: How to Create a Simple Dialog Box
« Reply #1 on: March 29, 2021, 01:58:11 PM »
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.

Re: How to Create a Simple Dialog Box
« Reply #2 on: March 29, 2021, 09:16:59 PM »
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!
Re: How to Create a Simple Dialog Box
« Reply #3 on: March 30, 2021, 03:12:42 AM »
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.

My wife left with my best friend...
     and I miss him!
Re: How to Create a Simple Dialog Box
« Reply #4 on: March 30, 2021, 12:32:09 PM »
If your OK and CANCEL buttons can be YES and NO instead, you could use something like this...

Code: [Select]
local response = wx.wxMessageBox("Message", "Title", wx.wxYES_NO)
if (response == 2) then
    -- user said YES
    -- user said NO