Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: jevs on October 20, 2019, 08:32:04 PM
-
I cannot figure out what this is doing. I don't know what that 16 is on the end and I cannot find documentation for it.
This pops up a message box with a selection of "Ok" and "Cancel"
local MyChoice = wx.wxMessageBox("Click Ok to Begin Probing the New Tool","Click OK to continue" , 16)
The problem is if you pick "Cancel" it does the same thing as "Ok" and continues on with the code below it. I need cancel to end the operation. Without any info
I cannot decipher what is going on here without knowing what that 16 does. I assume it is a choice of what to do from some list that I have no idea of.....
-
I kept digging. I never found any documentation, but I found another post on here with info that got me going..........
local rc = wx.wxMessageBox("This is my Message", "This is my Caption",16) --Ok, Cancel
--wxMessageBox Types
--2 = Yes, No
--4 = Ok
--16 = Ok, Cancel
--18 = Yes, No, Cancel
--wxMessageBox Return Values
--Yes = 2
--OK = 4
--No = 8
--Cancel = 16
It would still be nice to know where this is documented though. For now I made myself a text file with the info and put it in my docs folder.
-
You can find more info on wxMessageBox here: https://docs.wxwidgets.org/3.1/group__group__funcmacro__dialog.html#ga193c64ed4802e379799cdb42de252647 (https://docs.wxwidgets.org/3.1/group__group__funcmacro__dialog.html#ga193c64ed4802e379799cdb42de252647)
wxMessageBox uses styles from wxMessageDialog which can be found at the top of the page here: https://docs.wxwidgets.org/3.1/classwx_message_dialog.html (https://docs.wxwidgets.org/3.1/classwx_message_dialog.html)
The styles go where the '16' is in your example. So to show a message box with an 'Ok' button with an error symbol it would be the following
local rc = wx.wxMessageBox("This is my Message", "This is my Caption", wx.wxOK + wx.wxICON_ERROR)
In this case, if you selected the OK button, rc would be equal to 'wx.wxOK'.
Hope this helps
-
I did find those pages, but I did not find anything about those numbers representing different options. The numbers do work though and you can use them as variables to determine what to do with the answer after it is clicked.
Ultimately I have it working, but I still don't know how someone came to know about those numbers being different select options for the message box.
-
If anyone else stumbles upon this thread looking for answers, open this file from your computer that has Mach4 installed.......
C:\Mach4Hobby\LuaExamples\MessageBoxes.mcs
Best to open it with the Zero Brain Editor, but most text programs should open it.
I stumbled upon this today digging around for info.
-
Ultimately I have it working, but I still don't know how someone came to know about those numbers being different select options for the message box.
I do not remember exactly where but pretty sure they were in the wx docs somewhere.