summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>1999-01-26 21:37:14 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>1999-01-26 21:37:14 +0000
commit53d39cc6c0b1f4d2e3269fb505551d13b2653f2f (patch)
tree7f63cb89c66b2f0dd5230b6da4e1f0dcf63a4d0c
parentb983b285cc4f0627a1f72c9d6c510047af0ad116 (diff)
Applied a navigation bug fix from Bill.
git-svn-id: file:///fltk/svn/fltk/trunk@245 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--FL/Fl_Group.H6
-rw-r--r--src/Fl.cxx6
-rw-r--r--src/Fl_Group.cxx105
3 files changed, 67 insertions, 50 deletions
diff --git a/FL/Fl_Group.H b/FL/Fl_Group.H
index 934b9efd3..cc434d351 100644
--- a/FL/Fl_Group.H
+++ b/FL/Fl_Group.H
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Group.H,v 1.4 1999/01/07 19:16:55 mike Exp $"
+// "$Id: Fl_Group.H,v 1.5 1999/01/26 21:37:13 mike Exp $"
//
// Group header file for the Fast Light Tool Kit (FLTK).
//
@@ -38,7 +38,7 @@ class Fl_Group : public Fl_Widget {
int children_;
short *sizes_; // remembered initial sizes of children
- int navigation(int = 0);
+ int navigation(int);
static Fl_Group *current_;
protected:
@@ -96,5 +96,5 @@ public:
#endif
//
-// End of "$Id: Fl_Group.H,v 1.4 1999/01/07 19:16:55 mike Exp $".
+// End of "$Id: Fl_Group.H,v 1.5 1999/01/26 21:37:13 mike Exp $".
//
diff --git a/src/Fl.cxx b/src/Fl.cxx
index 423481d7c..fae4c980f 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl.cxx,v 1.15 1999/01/19 19:04:30 mike Exp $"
+// "$Id: Fl.cxx,v 1.16 1999/01/26 21:37:14 mike Exp $"
//
// Main event handling code for the Fast Light Tool Kit (FLTK).
//
@@ -45,7 +45,7 @@ int Fl::damage_,
Fl::e_clicks,
Fl::e_is_click,
Fl::e_keysym;
-char *Fl::e_text;
+char *Fl::e_text = "";
int Fl::e_length;
@@ -666,5 +666,5 @@ void Fl_Window::flush() {
}
//
-// End of "$Id: Fl.cxx,v 1.15 1999/01/19 19:04:30 mike Exp $".
+// End of "$Id: Fl.cxx,v 1.16 1999/01/26 21:37:14 mike Exp $".
//
diff --git a/src/Fl_Group.cxx b/src/Fl_Group.cxx
index 302c36885..fc41157d7 100644
--- a/src/Fl_Group.cxx
+++ b/src/Fl_Group.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Group.cxx,v 1.7 1999/01/24 15:28:58 mike Exp $"
+// "$Id: Fl_Group.cxx,v 1.8 1999/01/26 21:37:14 mike Exp $"
//
// Group widget for the Fast Light Tool Kit (FLTK).
//
@@ -63,6 +63,33 @@ static int send(Fl_Widget* o, int event) {
return ret;
}
+// translate the current keystroke into up/down/left/right for navigation:
+#define ctrl(x) (x^0x40)
+static int navkey() {
+ switch (Fl::event_key()) {
+ case FL_Tab:
+ if (!Fl::event_state(FL_SHIFT)) return FL_Right;
+ case 0xfe20: // XK_ISO_Left_Tab
+ return FL_Left;
+ case FL_Right:
+ return FL_Right;
+ case FL_Left:
+ return FL_Left;
+ case FL_Up:
+ return FL_Up;
+ case FL_Down:
+ return FL_Down;
+ default:
+ switch (Fl::event_text()[0]) {
+ case ctrl('N') : return FL_Down;
+ case ctrl('P') : return FL_Up;
+ case ctrl('F') : return FL_Right;
+ case ctrl('B') : return FL_Left;
+ }
+ }
+ return 0;
+}
+
int Fl_Group::handle(int event) {
Fl_Widget*const* a = array();
@@ -72,8 +99,18 @@ int Fl_Group::handle(int event) {
switch (event) {
case FL_FOCUS:
- if (savedfocus_ && savedfocus_->take_focus()) return 1;
- for (i = children(); i--;) if ((*a++)->take_focus()) return 1;
+ switch (navkey()) {
+ default:
+ if (savedfocus_ && savedfocus_->take_focus()) return 1;
+ case FL_Right:
+ case FL_Down:
+ for (i = children(); i--;) if ((*a++)->take_focus()) return 1;
+ break;
+ case FL_Left:
+ case FL_Up:
+ for (i = children(); i--;) if (a[i]->take_focus()) return 1;
+ break;
+ }
return 0;
case FL_UNFOCUS:
@@ -81,7 +118,7 @@ int Fl_Group::handle(int event) {
return 0;
case FL_KEYBOARD:
- return navigation();
+ return navigation(navkey());
case FL_SHORTCUT:
for (i = children(); i--;) {
@@ -147,33 +184,6 @@ int Fl_Group::handle(int event) {
}
}
-// translate the current keystroke into up/down/left/right for navigation:
-#define ctrl(x) (x^0x40)
-int navkey() {
- switch (Fl::event_key()) {
- case FL_Tab:
- if (!Fl::event_state(FL_SHIFT)) return FL_Right;
- case 0xfe20: // XK_ISO_Left_Tab
- return FL_Left;
- case FL_Right:
- return FL_Right;
- case FL_Left:
- return FL_Left;
- case FL_Up:
- return FL_Up;
- case FL_Down:
- return FL_Down;
- default:
- switch (Fl::event_text()[0]) {
- case ctrl('N') : return FL_Down;
- case ctrl('P') : return FL_Up;
- case ctrl('F') : return FL_Right;
- case ctrl('B') : return FL_Left;
- }
- }
- return 0;
-}
-
//void Fl_Group::focus(Fl_Widget *o) {Fl::focus(o); o->handle(FL_FOCUS);}
#if 0
@@ -187,35 +197,42 @@ const char *nameof(Fl_Widget *o) {
// try to move the focus in response to a keystroke:
int Fl_Group::navigation(int key) {
if (children() <= 1) return 0;
- if (!key) {key = navkey(); if (!key) return 0;}
- Fl_Widget *focus_ = Fl::focus();
- int old_i;
- for (old_i=0;;old_i++) {
- if (old_i >= children_) return 0;
- if (array_[old_i]->contains(focus_)) break;
+ int i;
+ for (i = 0; ; i++) {
+ if (i >= children_) return 0;
+ if (array_[i]->contains(Fl::focus())) break;
}
- int i = old_i;
+ Fl_Widget *previous = array_[i];
for (;;) {
switch (key) {
case FL_Right:
case FL_Down:
- i++; if (i >= children_) i = 0;
+ i++;
+ if (i >= children_) {
+ if (parent()) return 0;
+ i = 0;
+ }
break;
case FL_Left:
case FL_Up:
- if (i) i--; else i = children_-1;
+ if (i) i--;
+ else {
+ if (parent()) return 0;
+ i = children_-1;
+ }
break;
default:
return 0;
}
- if (i == old_i) return 0;
Fl_Widget* o = array_[i];
+ if (o == previous) return 0;
switch (key) {
case FL_Down:
case FL_Up:
- if (o->x() >= focus_->x()+focus_->w() ||
- o->x()+o->w() <= focus_->x()) continue;
+ // for up/down, the widgets have to overlap horizontally:
+ if (o->x() >= previous->x()+previous->w() ||
+ o->x()+o->w() <= previous->x()) continue;
}
if (o->take_focus()) return 1;
}
@@ -468,5 +485,5 @@ void Fl_Group::draw_outside_label(const Fl_Widget& w) const {
}
//
-// End of "$Id: Fl_Group.cxx,v 1.7 1999/01/24 15:28:58 mike Exp $".
+// End of "$Id: Fl_Group.cxx,v 1.8 1999/01/26 21:37:14 mike Exp $".
//