Hello Guest it is March 29, 2024, 08:06:41 AM

Author Topic: Message Box with Cancel?  (Read 7845 times)

0 Members and 1 Guest are viewing this topic.

Message Box with Cancel?
« on: December 21, 2017, 09:22:21 AM »
So the simple wx.messagebox is great.  But is there a wx.widget that gives me a message box with "Okay" and "Cancel" as options to choose?
Chad Byrd

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Message Box with Cancel?
« Reply #1 on: December 21, 2017, 09:47:11 AM »
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
« Last Edit: December 21, 2017, 09:52:11 AM by Chaoticone »
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Message Box with Cancel?
« Reply #2 on: December 21, 2017, 10:04:30 AM »
Yes!   Awesome, I'm going to try this once I get back to the shop today. 
Chad Byrd
Re: Message Box with Cancel?
« Reply #3 on: February 08, 2018, 10:00:31 AM »
So,  I've got another message box question.
Is there a way I can have a user type in a number in a message box, and then use that number to set an offset?
Chad Byrd

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Message Box with Cancel?
« Reply #4 on: February 08, 2018, 11:25:06 AM »
Sure is..........

local MyNum = wx.wxGetNumberFromUser("Message", "Prompt", "Caption", 50, 0, 100) --Default, min, max

Or you can get it as a string and then convert it to a number. Can do some checks with either, flip numbers, etc. Goods and bads using both methods. Just have to figure out what works best for you and your condition.

local MyText = wx.wxGetTextFromUser("Message", "Caption", "Default Value")

;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Message Box with Cancel?
« Reply #5 on: February 08, 2018, 11:33:03 AM »
Okay.  Very nice.  I'll have to play with it and see what works well.
Just to let you know what I'm trying to accomplish:
On the lathe we are retrofitting, I want to prompt the operator on startup to enter the current tool in the turret.  Just in case Mach4 is shut down before retaining the current tool. 
Chad Byrd
Re: Message Box with Cancel?
« Reply #6 on: February 08, 2018, 11:39:27 AM »
Excellent!
Works perfectly!  Since I'm using a number.  wx.wxGetNumberFromUser works great!
Chad Byrd
Re: Message Box with Cancel?
« Reply #7 on: February 08, 2018, 11:53:20 AM »
Do you know what the Return Values are for this, I can't seem to find them?  If the operator hits "cancel" I want to Pop up the User Input Box again.
Chad Byrd
Re: Message Box with Cancel?
« Reply #8 on: February 08, 2018, 12:02:46 PM »
Okay, So, I've found the Return Value I need.  But how do I get my syntax correct.  

local ActualTool, rc = wx.wxGetNumberFromUser()
if rc == -1 then
mc.mcCntlSetLastError(inst, "ERROR")
else
mc.mcToolSetCurrent(inst, ActualTool)
end

This isn't working correctly.  When I hit cancel, it puts a "-1" in my current tool and skips over the    if rc == -1
Obviously I have something wrong.  

If I just have rc =wx.wxGetNumberFromUser() everything works properly.  But I wold rather have the variable "Actual Tool" instead of just "rc"

Chad Byrd
Re: Message Box with Cancel?
« Reply #9 on: February 08, 2018, 01:04:25 PM »
I'm not sure if this is the "correct" way to do this.  But it works for my proof of concept.

--What is the current tool?
function m110()

local inst = mc.mcGetInstance()
local ActualTool = wx.wxGetNumberFromUser("What tool is in the turret?", "Tool # ","Current Tool", 1, 1, 6) -- Default, Min, Max.
local rc = ActualTool
if rc == -1 then
wx.wxMessageBox("Set the current tool to the actual tool.")
else
mc.mcToolSetCurrent(inst, ActualTool)
end

end --m110

if (mc.mcInEditor() == 1) then
 m110()
end
Chad Byrd