Re: findbar behaviour

"corvid" <[email protected]>
Newsgroups gmane.comp.web.dillo.devel
Message-ID <20121226232950.GB13790@local>
Here's what resulted, but it seems relatively inelegant:

_______________________________________________
Dillo-dev mailing list
[email protected]
http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev
findbar_keyboard2.diff (text/plain, 2.5 KB)
diff -r 82f4a72a0aff src/findbar.cc
--- a/src/findbar.cc	Wed Dec 26 20:08:46 2012 +0100
+++ b/src/findbar.cc	Wed Dec 26 23:27:30 2012 +0000
@@ -137,9 +137,7 @@
 
     next_btn = new CustButton(x, border, button_width, height, "Next");
     x += button_width + gap;
-    next_btn->shortcut(FL_Enter);
     next_btn->callback(search_cb, this);
-    next_btn->clear_visible_focus();
     next_btn->box(FL_THIN_UP_BOX);
     next_btn->set_tooltip("Find next occurrence of the search phrase\n"
                           "shortcut: Enter");
@@ -147,9 +145,7 @@
 
     prev_btn= new CustButton(x, border, button_width, height, "Previous");
     x += button_width + gap;
-    prev_btn->shortcut(FL_SHIFT+FL_Enter);
     prev_btn->callback(searchBackwards_cb, this);
-    prev_btn->clear_visible_focus();
     prev_btn->box(FL_THIN_UP_BOX);
     prev_btn->set_tooltip("Find previous occurrence of the search phrase\n"
                           "shortcut: Shift+Enter");
@@ -158,7 +154,6 @@
     check_btn = new Fl_Check_Button(x, border, 2*button_width, height,
                               "Case-sensitive");
     x += 2 * button_width + gap;
-    check_btn->clear_visible_focus();
    add(check_btn);
 
 }
@@ -176,9 +171,35 @@
    int k = Fl::event_key();
    unsigned modifier = Fl::event_state() & (FL_SHIFT| FL_CTRL| FL_ALT|FL_META);
 
-   if (event == FL_KEYBOARD && modifier == 0 && k == FL_Escape) {
-      /* let the UI handle it */
-      return 0;
+   if (event == FL_KEYBOARD) {
+      if (k == FL_Escape && modifier == 0) {
+         /* let the UI handle it */
+         return 0;
+      } else if (k == FL_Tab) {
+         if (Fl_Group::handle(event) == 0) {
+            // make focus cycle around
+            if (Fl::event_shift())
+               check_btn->take_focus();
+            else
+               i->take_focus();
+         }
+         return 1;
+      } else if (k == FL_Enter) {
+         if (Fl::focus() == next_btn || Fl::focus() == prev_btn)
+            ((Fl_Button *)Fl::focus())->set();
+         if (Fl::focus() == check_btn)
+            check_btn->value(!check_btn->value());
+         else if (Fl::focus() == prev_btn ||
+                 (Fl::focus() == i && Fl::event_shift()))
+            searchBackwards_cb(Fl::focus(), (void*)this);
+         else
+            search_cb(Fl::focus(), (void*)this);
+         return 1;
+      }
+   } else if (event == FL_KEYUP) {
+      if (Fl::focus() == next_btn || Fl::focus() == prev_btn)
+         ((Fl_Button *)Fl::focus())->clear();
+      return 1;
    }
 
    return Fl_Group::handle(event);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.