Fix ESC handling in automation dialogs when no button IDs are set

Closes #1660.
This commit is contained in:
Thomas Goyne 2013-11-09 06:17:40 -08:00
parent f0ef14669f
commit 466b69ba59

View file

@ -406,7 +406,7 @@ namespace Automation4 {
// LuaDialog
LuaDialog::LuaDialog(lua_State *L, bool include_buttons)
: use_buttons(include_buttons)
, button_pushed(0)
, button_pushed(-1)
, window(0)
{
LOG_D("automation/lua/dialog") << "creating LuaDialoug, addr: " << this;
@ -536,7 +536,7 @@ namespace Automation4 {
int LuaDialog::LuaReadBack(lua_State *L) {
// First read back which button was pressed, if any
if (use_buttons) {
if (buttons[button_pushed].first == wxID_CANCEL)
if (button_pushed == -1 || buttons[button_pushed].first == wxID_CANCEL)
lua_pushboolean(L, false);
else
lua_pushstring(L, buttons[button_pushed].second.c_str());