Disable the escape in some dialogs.

Like the old dialogs disable the escape when a textbox or input list is
shown.
This commit is contained in:
Mark de Wever 2009-02-02 21:35:02 +00:00
parent 8d0bb53956
commit 57b7287741
3 changed files with 18 additions and 1 deletions

View file

@ -90,6 +90,7 @@ void twml_message_::pre_show(CVideo& video, twindow& window)
input->set_maximum_length(input_maximum_lenght_);
window.keyboard_capture(input);
window.set_easy_close(false);
window.set_escape_disabled(true);
} else {
caption->set_visible(twidget::INVISIBLE);
input->set_visible(twidget::INVISIBLE);
@ -182,6 +183,7 @@ void twml_message_::pre_show(CVideo& video, twindow& window)
if(!has_input_) {
window.keyboard_capture(options);
window.set_easy_close(false);
window.set_escape_disabled(true);
} else {
window.add_to_keyboard_chain(options);
// easy_close has been disabled due to the input.

View file

@ -115,6 +115,7 @@ twindow::twindow(CVideo& video,
, h_(h)
, easy_close_(false)
, easy_close_blocker_()
, escape_disabled_(false)
, dirty_list_()
#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
, debug_layout_(new tdebug_layout_graph(this))
@ -406,7 +407,7 @@ void twindow::key_press(tevent_handler& /*event_handler*/, bool& handled,
if(key == SDLK_KP_ENTER || key == SDLK_RETURN) {
set_retval(OK);
handled = true;
} else if(key == SDLK_ESCAPE) {
} else if(key == SDLK_ESCAPE && !escape_disabled_) {
set_retval(CANCEL);
handled = true;
} else if(key == SDLK_SPACE) {

View file

@ -231,6 +231,17 @@ public:
bool does_easy_close() const
{ return easy_close_ && easy_close_blocker_.empty(); }
/**
* Disable the escape key.
*
* This is added to block dialogs from being closed automatically.
*
* @todo this function should be merged with the hotkey support once
* that has been added.
*/
void set_escape_disabled(const bool escape_disabled)
{ escape_disabled_ = escape_disabled; }
/***** ***** ***** setters / getters for members ***** ****** *****/
/**
@ -335,6 +346,9 @@ private:
/** The list with items which prevent the easy close behaviour. */
std::vector<std::string> easy_close_blocker_;
/** Disable the escape key see our setter for more info. */
bool escape_disabled_;
/**
* Controls the sunset feature.
*