mail[Wesnoth-commits] r33212 - in /trunk: ./ src/gui/widgets/


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by koraq on March 01, 2009 - 11:38:
Author: mordante
Date: Sun Mar  1 11:38:50 2009
New Revision: 33212

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33212&view=rev
Log:
Changed the textbox history.

The textbox history now uses CTRL+TAB and CTRL+SHIFT+TAB so the arrow
keys are no longer overloaded. It would be nice to make these keys
configurable, but that will be postponed until post 1.6.

Modified:
    trunk/changelog
    trunk/players_changelog
    trunk/src/gui/widgets/text.hpp
    trunk/src/gui/widgets/text_box.cpp
    trunk/src/gui/widgets/text_box.hpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=33212&r1=33211&r2=33212&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Sun Mar  1 11:38:50 2009
@@ -16,6 +16,7 @@
    * Fix broken auto-undo when trying several move+attack with the same unit
    * Changed the widgets in the in game message dialog
    * The multiplayer dialog shows tooltips again
+   * The textbox history now uses CTRL+TAB and CTRL+SHIFT+TAB
  * WML Engine:
    * Fix incorrect or doubled "sighted" events when delaying shroud update
    * Fix sometimes doubled "select" events

Modified: trunk/players_changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/players_changelog?rev=33212&r1=33211&r2=33212&view=diff
==============================================================================
--- trunk/players_changelog (original)
+++ trunk/players_changelog Sun Mar  1 11:38:50 2009
@@ -11,6 +11,7 @@
     * Now clear fog/shroud before an attack when doing a move+attack action.
     * Changed the widgets in the in game message dialog.
     * The multiplayer dialog shows tooltips again.
+    * The textbox history now uses CTRL+TAB and CTRL+SHIFT+TAB.
 
 Version 1.5.11:
   * Graphics

Modified: trunk/src/gui/widgets/text.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/text.hpp?rev=33212&r1=33211&r2=33212&view=diff
==============================================================================
--- trunk/src/gui/widgets/text.hpp (original)
+++ trunk/src/gui/widgets/text.hpp Sun Mar  1 11:38:50 2009
@@ -365,6 +365,7 @@
         */
        virtual void handle_key_page_down(SDLMod /*modifier*/, bool& 
/*handled*/) {}
 
+protected:
        /**
         * Default key handler if none of the above functions is called.
         *

Modified: trunk/src/gui/widgets/text_box.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/text_box.cpp?rev=33212&r1=33211&r2=33212&view=diff
==============================================================================
--- trunk/src/gui/widgets/text_box.cpp (original)
+++ trunk/src/gui/widgets/text_box.cpp Sun Mar  1 11:38:50 2009
@@ -262,23 +262,46 @@
        update_canvas();
 }
 
-void ttext_box::handle_key_up_arrow(SDLMod /*modifier*/, bool& handled)
-{
-       if (history_.get_enabled()) {
-               std::string s = history_.up(get_value());
-               if (!s.empty()) {
-                       set_value(s);
+bool ttext_box::history_up()
+{
+       if(!history_.get_enabled()) {
+               return false;
+       }
+
+       const std::string str = history_.up(get_value());
+       if(!str.empty()) {
+               set_value(str);
+       }
+       return true;
+}
+
+bool ttext_box::history_down()
+{
+       if(!history_.get_enabled()) {
+               return false;
+       }
+
+       const std::string str = history_.down(get_value());
+       if(!str.empty()) {
+               set_value(str);
+       }
+       return true;
+}
+
+void ttext_box::handle_key_default(
+               bool& handled, SDLKey key, SDLMod modifier, Uint16 unicode)
+{
+       if(key == SDLK_TAB && (modifier & KMOD_CTRL)) {
+               if(!(modifier& KMOD_SHIFT)) {
+                       handled = history_up();
+               } else {
+                       handled = history_down();
                }
-
-               handled = true;
-       }
-}
-
-void ttext_box::handle_key_down_arrow(SDLMod /*modifier*/, bool& handled)
-{
-       if (history_.get_enabled()) {
-               set_value(history_.down(get_value()));
-               handled = true;
+       }
+
+       if(!handled) {
+               // Inherited.
+               ttext_::handle_key_default(handled, key, modifier, unicode);
        }
 }
 

Modified: trunk/src/gui/widgets/text_box.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/text_box.hpp?rev=33212&r1=33211&r2=33212&view=diff
==============================================================================
--- trunk/src/gui/widgets/text_box.hpp (original)
+++ trunk/src/gui/widgets/text_box.hpp Sun Mar  1 11:38:50 2009
@@ -210,24 +210,40 @@
        /**
         * Inherited from ttext_.
         *
-        * Unmodified                 If there is a history, goes one item up 
in the
-        *                            history, otherwise ignored.
+        * Unmodified                 Unhandled.
         * Control                    Ignored.
         * Shift                      Ignored.
         * Alt                        Ignored.
         */
-       void handle_key_up_arrow(SDLMod modifier, bool& handled);
+       void handle_key_up_arrow(SDLMod /*modifier*/, bool& /*handled*/) {}
 
        /**
         * Inherited from ttext_.
         *
-        * Unmodified                 If there is a history, goes one item 
down in the
-        *                            history, otherwise ignored.
+        * Unmodified                 Unhandled.
         * Control                    Ignored.
         * Shift                      Ignored.
         * Alt                        Ignored.
         */
-       void handle_key_down_arrow(SDLMod modifier, bool& handled);
+       void handle_key_down_arrow(SDLMod /*modifier*/, bool& /*handled*/) {}
+
+       /**
+        * Goes one item up in the history.
+        *
+        * @returns                   True if there's a history, false 
otherwise.
+        */
+       bool history_up();      
+
+       /**
+        * Goes one item down in the history.
+        *
+        * @returns                   True if there's a history, false 
otherwise.
+        */
+       bool history_down();    
+
+       /** Inherited from ttext_. */
+       void handle_key_default(
+               bool& handled, SDLKey key, SDLMod modifier, Uint16 unicode);
 
        /** Inherited from ttext_. */
        void handle_key_clear_line(SDLMod modifier, bool& handled);




Related Messages


Powered by MHonArc, Updated Sun Mar 01 12:20:06 2009