changeset 2032:1a32d5ed2cd7

Made KEYS_LEFT_TAB and KEYS_RIGHT_TAB no longer handled as a special case * Made TAB-key focus the main area from location input. * Made KEYS_LEFT_TAB and KEYS_RIGHT_TAB cycle..
author Jorge Arellano Cid <jcid@dillo.org>
date Tue, 17 May 2011 18:57:29 -0400
parents ae8f0d070aea
children 56134df9c63a
files src/ui.cc src/uicmd.cc
diffstat 2 files changed, 15 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/ui.cc	Tue May 17 13:58:58 2011 -0400
+++ b/src/ui.cc	Tue May 17 18:57:29 2011 -0400
@@ -93,8 +93,8 @@
 };
 
 /*
- * Disable keys: Up, Down, Page_Up, Page_Down and
- * CTRL+{o,r,Home,End}
+ * Disable keys: Up, Down, Page_Up, Page_Down, Tab and
+ * CTRL+{o,r,Home,End}  SHIFT+{Left,Right}.
  */
 int CustInput::handle(int e)
 {
@@ -113,7 +113,11 @@
       if (k == FL_Escape && modifier == 0) {
          // Let the parent group handle this Esc key
          return 0;
-
+      } else if (modifier == FL_SHIFT) {
+         if (k == FL_Left || k == FL_Right) {
+            // Let these keys get to the UI
+            return 0;
+         }
       } else if (modifier == FL_CTRL) {
          if (k == 'l') {
             // Make text selected when already focused.
@@ -126,7 +130,7 @@
          }
       } else if (modifier == 0) {
          if (k == FL_Down || k == FL_Up ||
-             k == FL_Page_Down || k == FL_Page_Up) {
+             k == FL_Page_Down || k == FL_Page_Up || k == FL_Tab) {
             // Give up focus and honor the key
             a_UIcmd_focus_main_area(a_UIcmd_get_bw_by_widget(this));
             return 0;
--- a/src/uicmd.cc	Tue May 17 13:58:58 2011 -0400
+++ b/src/uicmd.cc	Tue May 17 18:57:29 2011 -0400
@@ -149,6 +149,7 @@
          ret = 1;
       } else if (cmd == KEYS_NOP) {
          // Do nothing
+         _MSG("CustTabs::handle KEYS_NOP\n");
       } else if (cmd == KEYS_NEW_TAB) {
          a_UIcmd_open_url_nt(bw, NULL, 1);
          ret = 1;
@@ -156,10 +157,10 @@
          a_UIcmd_close_bw(bw);
          ret = 1;
       } else if (cmd == KEYS_LEFT_TAB) {
-         MSG("CustTabs::handle KEYS_LEFT_TAB\n");
+         prev_tab();
          ret = 1;
       } else if (cmd == KEYS_RIGHT_TAB) {
-         MSG("CustTabs::handle KEYS_RIGHT_TAB\n");
+         next_tab();
          ret = 1;
       } else if (cmd == KEYS_NEW_WINDOW) {
          a_UIcmd_open_url_nw(bw, NULL);
@@ -171,19 +172,6 @@
          a_Timeout_add(0.0, a_UIcmd_close_all_bw, NULL);
          ret = 1;
       }
-
-   } else if (e == FL_KEYUP) {
-      int k = Fl::event_key();
-      // We're only interested in some flags
-      unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT);
-      if (k == FL_Up || k == FL_Down || k == FL_Tab) {
-         ;
-      } else if (k == FL_Left || k == FL_Right) {
-         if (modifier == FL_SHIFT) {
-            (k == FL_Left) ? prev_tab() : next_tab();
-            ret = 1;
-         }
-      }
    }
 
    return (ret) ? ret : CustGroup::handle(e);
@@ -285,16 +273,16 @@
 {
    int idx;
 
-   if ((idx = get_btn_idx((UI*)Wizard->value())) > 1)
-      switch_tab( (CustTabButton*)child(idx-1) );
+   if ((idx = get_btn_idx((UI*)Wizard->value())) != -1)
+      switch_tab( (CustTabButton*)child(idx > 1 ? idx-1 : num_tabs()) );
 }
 
 void CustTabs::next_tab()
 {
    int idx;
 
-   if ((idx = get_btn_idx((UI*)Wizard->value())) > 0 && idx < num_tabs())
-      switch_tab( (CustTabButton*)child(idx+1) );
+   if ((idx = get_btn_idx((UI*)Wizard->value())) != -1)
+      switch_tab( (CustTabButton*)child(idx < num_tabs() ? idx+1 : 1) );
 }
 
 /*