Author: mordante
Date: Mon Feb  2 22:35:02 2009
New Revision: 32558

URL: http://svn.gna.org/viewcvs/wesnoth?rev=32558&view=rev
Log:
Disable the escape in some dialogs.

Like the old dialogs disable the escape when a textbox or input list is
shown.

Modified:
    trunk/src/gui/dialogs/wml_message.cpp
    trunk/src/gui/widgets/window.cpp
    trunk/src/gui/widgets/window.hpp

Modified: trunk/src/gui/dialogs/wml_message.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/wml_message.cpp?rev=32558&r1=32557&r2=32558&view=diff
==============================================================================
--- trunk/src/gui/dialogs/wml_message.cpp (original)
+++ trunk/src/gui/dialogs/wml_message.cpp Mon Feb  2 22:35:02 2009
@@ -90,6 +90,7 @@
                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 @@
                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.

Modified: trunk/src/gui/widgets/window.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.cpp?rev=32558&r1=32557&r2=32558&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.cpp (original)
+++ trunk/src/gui/widgets/window.cpp Mon Feb  2 22:35:02 2009
@@ -115,6 +115,7 @@
        , 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 @@
        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) {

Modified: trunk/src/gui/widgets/window.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.hpp?rev=32558&r1=32557&r2=32558&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.hpp (original)
+++ trunk/src/gui/widgets/window.hpp Mon Feb  2 22:35:02 2009
@@ -231,6 +231,17 @@
        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 ***** ****** *****/
 
        /**
@@ -334,6 +345,9 @@
 
        /** 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.


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to