make 'Cancel' work in command dialogs

This commit is contained in:
thrust26 2019-05-04 12:55:39 +02:00
parent 951b13ed97
commit 39d3eefcef
6 changed files with 74 additions and 51 deletions

View File

@ -101,6 +101,10 @@ CommandDialog::CommandDialog(OSystem& osystem, DialogContainer& parent)
wid.push_back(bw);
addToFocusList(wid);
// We don't have a close/cancel button, but we still want the cancel
// event to be processed
processCancelWithoutWidget(true);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -233,6 +237,12 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd,
instance().eventHandler().handleEvent(event);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CommandDialog::processCancel()
{
instance().eventHandler().leaveMenuMode();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CommandDialog::updateSlot(int slot)
{

View File

@ -37,6 +37,7 @@ class CommandDialog : public Dialog
void updateSlot(int slot);
void updateTVFormat();
void updatePalette();
void processCancel() override;
// column 0
ButtonWidget* myColorButton;

View File

@ -722,7 +722,7 @@ bool Dialog::handleNavEvent(Event::Type e)
{
// Some dialogs want the ability to cancel without actually having
// a corresponding cancel button
close();
processCancel();
return true;
}
break;

View File

@ -159,6 +159,7 @@ class Dialog : public GuiObject
bool focusOKButton = true);
void processCancelWithoutWidget(bool state) { _processCancel = state; }
virtual void processCancel() { close(); }
/** Define the size (allowed) for the dialog. */
void setSize(uInt32 w, uInt32 h, uInt32 max_w, uInt32 max_h);

View File

@ -104,6 +104,10 @@ MinUICommandDialog::MinUICommandDialog(OSystem& osystem, DialogContainer& parent
wid.push_back(bw);
addToFocusList(wid);
// We don't have a close/cancel button, but we still want the cancel
// event to be processed
processCancelWithoutWidget(true);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -248,6 +252,12 @@ void MinUICommandDialog::handleCommand(CommandSender* sender, int cmd,
instance().eventHandler().handleEvent(event);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MinUICommandDialog::processCancel()
{
instance().eventHandler().leaveMenuMode();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MinUICommandDialog::updateSlot(int slot)
{

View File

@ -41,6 +41,7 @@ class MinUICommandDialog : public Dialog
void updateWinds();
void updateTVFormat();
void openSettings();
void processCancel() override;
// column 0
ButtonWidget* myColorButton;