Update all non-text widgets that take keyboard focus to check

Fl::visible_focus() before taking or accepting focus; this allows
one to disable the new 1.1 keyboard focus stuff completely (not much
sense allowing focus if you can't see it...)


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1679 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2001-11-03 19:24:22 +00:00
parent d3acd6c475
commit 0884e2ba0d
13 changed files with 81 additions and 53 deletions

View File

@ -14,6 +14,10 @@ CHANGES IN FLTK 1.1.0
whether the focus box is drawn.
- The focus box is now drawn using the contrast color.
- Fl_Repeat_Button didn't accept keyboard focus.
- Added new Fl::visible_focus() method and standard
"-kbd" and "-nokbd" options in Fl::args() processing
to control whether keyboard focus is shown and handled
by non-text widgets.
CHANGES IN FLTK 1.1.0b5

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Adjuster.cxx,v 1.5.2.3.2.2 2001/10/29 03:44:32 easysw Exp $"
// "$Id: Fl_Adjuster.cxx,v 1.5.2.3.2.3 2001/11/03 19:24:22 easysw Exp $"
//
// Adjuster widget for the Fast Light Tool Kit (FLTK).
//
@ -70,7 +70,7 @@ int Fl_Adjuster::handle(int event) {
int mx = Fl::event_x();
switch (event) {
case FL_PUSH:
take_focus();
if (Fl::visible_focus()) take_focus();
ix = mx;
if (w()>=h())
drag = 3*(mx-x())/w() + 1;
@ -142,8 +142,10 @@ int Fl_Adjuster::handle(int event) {
break;
case FL_FOCUS:
case FL_UNFOCUS:
redraw();
return 1;
if (Fl::visible_focus()) {
redraw();
return 1;
} else return 0;
}
return 0;
}
@ -158,5 +160,5 @@ Fl_Adjuster::Fl_Adjuster(int x, int y, int w, int h, const char* l)
}
//
// End of "$Id: Fl_Adjuster.cxx,v 1.5.2.3.2.2 2001/10/29 03:44:32 easysw Exp $".
// End of "$Id: Fl_Adjuster.cxx,v 1.5.2.3.2.3 2001/11/03 19:24:22 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Browser_.cxx,v 1.10.2.16.2.7 2001/10/29 03:44:32 easysw Exp $"
// "$Id: Fl_Browser_.cxx,v 1.10.2.16.2.8 2001/11/03 19:24:22 easysw Exp $"
//
// Base Browser widget class for the Fast Light Tool Kit (FLTK).
//
@ -552,7 +552,7 @@ int Fl_Browser_::handle(int event) {
switch (event) {
case FL_PUSH:
if (!Fl::event_inside(X, Y, W, H)) return 0;
take_focus();
if (Fl::visible_focus()) take_focus();
my = py = Fl::event_y();
change = 0;
if (type() == FL_NORMAL_BROWSER || !top_)
@ -649,7 +649,7 @@ int Fl_Browser_::handle(int event) {
return 1;
case FL_FOCUS:
case FL_UNFOCUS:
if (type() >= FL_HOLD_BROWSER) {
if (type() >= FL_HOLD_BROWSER && Fl::visible_focus()) {
redraw();
return 1;
} else return 0;
@ -713,5 +713,5 @@ void Fl_Browser_::item_select(void*, int) {}
int Fl_Browser_::item_selected(void* l) const {return l==selection_;}
//
// End of "$Id: Fl_Browser_.cxx,v 1.10.2.16.2.7 2001/10/29 03:44:32 easysw Exp $".
// End of "$Id: Fl_Browser_.cxx,v 1.10.2.16.2.8 2001/11/03 19:24:22 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Button.cxx,v 1.4.2.6.2.4 2001/08/04 20:17:10 easysw Exp $"
// "$Id: Fl_Button.cxx,v 1.4.2.6.2.5 2001/11/03 19:24:22 easysw Exp $"
//
// Button widget for the Fast Light Tool Kit (FLTK).
//
@ -66,7 +66,7 @@ int Fl_Button::handle(int event) {
return 1;
case FL_PUSH:
case FL_DRAG:
take_focus();
if (Fl::visible_focus()) take_focus();
if (Fl::event_inside(this)) {
if (type() == FL_RADIO_BUTTON) newval = 1;
else newval = !oldval;
@ -107,8 +107,10 @@ int Fl_Button::handle(int event) {
return 1;
case FL_FOCUS :
case FL_UNFOCUS :
redraw();
return 1;
if (Fl::visible_focus()) {
redraw();
return 1;
} else return 0;
case FL_KEYBOARD :
if (Fl::focus() == this && Fl::event_key() == ' ') {
if (type() == FL_RADIO_BUTTON && !value_) {
@ -136,5 +138,5 @@ Fl_Button::Fl_Button(int x,int y,int w,int h, const char *l)
}
//
// End of "$Id: Fl_Button.cxx,v 1.4.2.6.2.4 2001/08/04 20:17:10 easysw Exp $".
// End of "$Id: Fl_Button.cxx,v 1.4.2.6.2.5 2001/11/03 19:24:22 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Choice.cxx,v 1.10.2.5.2.2 2001/09/29 22:59:45 easysw Exp $"
// "$Id: Fl_Choice.cxx,v 1.10.2.5.2.3 2001/11/03 19:24:22 easysw Exp $"
//
// Choice widget for the Fast Light Tool Kit (FLTK).
//
@ -89,7 +89,7 @@ int Fl_Choice::handle(int e) {
case FL_KEYBOARD:
if (Fl::event_key() != ' ') return 0;
case FL_PUSH:
take_focus();
if (Fl::visible_focus()) take_focus();
Fl::event_is_click(0);
J1:
v = menu()->pulldown(x(), y(), w(), h(), mvalue(), this);
@ -106,13 +106,15 @@ int Fl_Choice::handle(int e) {
return 1;
case FL_FOCUS:
case FL_UNFOCUS:
redraw();
return 1;
if (Fl::visible_focus()) {
redraw();
return 1;
} else return 0;
default:
return 0;
}
}
//
// End of "$Id: Fl_Choice.cxx,v 1.10.2.5.2.2 2001/09/29 22:59:45 easysw Exp $".
// End of "$Id: Fl_Choice.cxx,v 1.10.2.5.2.3 2001/11/03 19:24:22 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Counter.cxx,v 1.8.2.3.2.3 2001/10/29 03:44:32 easysw Exp $"
// "$Id: Fl_Counter.cxx,v 1.8.2.3.2.4 2001/11/03 19:24:22 easysw Exp $"
//
// Counter widget for the Fast Light Tool Kit (FLTK).
//
@ -131,7 +131,7 @@ int Fl_Counter::handle(int event) {
handle_release();
return 1;
case FL_PUSH:
take_focus();
if (Fl::visible_focus()) take_focus();
handle_push();
case FL_DRAG:
i = calc_mouseobj();
@ -157,8 +157,10 @@ int Fl_Counter::handle(int event) {
break;
case FL_FOCUS :
case FL_UNFOCUS :
damage(FL_DAMAGE_ALL);
return 1;
if (Fl::visible_focus()) {
redraw();
return 1;
} else return 0;
case FL_ENTER :
case FL_LEAVE :
return 1;
@ -186,5 +188,5 @@ Fl_Counter::Fl_Counter(int x, int y, int w, int h, const char* l)
}
//
// End of "$Id: Fl_Counter.cxx,v 1.8.2.3.2.3 2001/10/29 03:44:32 easysw Exp $".
// End of "$Id: Fl_Counter.cxx,v 1.8.2.3.2.4 2001/11/03 19:24:22 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Menu_Button.cxx,v 1.4.2.3.2.1 2001/08/04 20:17:10 easysw Exp $"
// "$Id: Fl_Menu_Button.cxx,v 1.4.2.3.2.2 2001/11/03 19:24:22 easysw Exp $"
//
// Menu button widget for the Fast Light Tool Kit (FLTK).
//
@ -65,7 +65,7 @@ int Fl_Menu_Button::handle(int e) {
} else if (type()) {
if (!(type() & (1 << (Fl::event_button()-1)))) return 0;
}
take_focus();
if (Fl::visible_focus()) take_focus();
popup();
return 1;
case FL_KEYBOARD:
@ -78,7 +78,7 @@ int Fl_Menu_Button::handle(int e) {
return test_shortcut() != 0;
case FL_FOCUS:
case FL_UNFOCUS:
if (box()) {
if (box() && Fl::visible_focus()) {
redraw();
return 1;
}
@ -93,5 +93,5 @@ Fl_Menu_Button::Fl_Menu_Button(int X,int Y,int W,int H,const char *l)
}
//
// End of "$Id: Fl_Menu_Button.cxx,v 1.4.2.3.2.1 2001/08/04 20:17:10 easysw Exp $".
// End of "$Id: Fl_Menu_Button.cxx,v 1.4.2.3.2.2 2001/11/03 19:24:22 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Repeat_Button.cxx,v 1.4.2.4.2.1 2001/11/03 05:11:34 easysw Exp $"
// "$Id: Fl_Repeat_Button.cxx,v 1.4.2.4.2.2 2001/11/03 19:24:22 easysw Exp $"
//
// Repeat button widget for the Fast Light Tool Kit (FLTK).
//
@ -44,7 +44,7 @@ int Fl_Repeat_Button::handle(int event) {
newval = 0; goto J1;
case FL_PUSH:
case FL_DRAG:
take_focus();
if (Fl::visible_focus()) take_focus();
newval = Fl::event_inside(this);
J1:
if (value(newval)) {
@ -62,5 +62,5 @@ int Fl_Repeat_Button::handle(int event) {
}
//
// End of "$Id: Fl_Repeat_Button.cxx,v 1.4.2.4.2.1 2001/11/03 05:11:34 easysw Exp $".
// End of "$Id: Fl_Repeat_Button.cxx,v 1.4.2.4.2.2 2001/11/03 19:24:22 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Roller.cxx,v 1.6.2.4.2.1 2001/08/05 14:00:15 easysw Exp $"
// "$Id: Fl_Roller.cxx,v 1.6.2.4.2.2 2001/11/03 19:24:22 easysw Exp $"
//
// Roller widget for the Fast Light Tool Kit (FLTK).
//
@ -35,7 +35,7 @@ int Fl_Roller::handle(int event) {
int newpos = horizontal() ? Fl::event_x() : Fl::event_y();
switch (event) {
case FL_PUSH:
take_focus();
if (Fl::visible_focus()) take_focus();
handle_push();
ipos = newpos;
return 1;
@ -69,8 +69,10 @@ int Fl_Roller::handle(int event) {
break;
case FL_FOCUS :
case FL_UNFOCUS :
damage(FL_DAMAGE_ALL);
return 1;
if (Fl::visible_focus()) {
redraw();
return 1;
} else return 0;
default:
return 0;
}
@ -166,5 +168,5 @@ Fl_Roller::Fl_Roller(int X,int Y,int W,int H,const char* L)
}
//
// End of "$Id: Fl_Roller.cxx,v 1.6.2.4.2.1 2001/08/05 14:00:15 easysw Exp $".
// End of "$Id: Fl_Roller.cxx,v 1.6.2.4.2.2 2001/11/03 19:24:22 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Scrollbar.cxx,v 1.7.2.14.2.3 2001/10/29 03:44:32 easysw Exp $"
// "$Id: Fl_Scrollbar.cxx,v 1.7.2.14.2.4 2001/11/03 19:24:22 easysw Exp $"
//
// Scroll bar widget for the Fast Light Tool Kit (FLTK).
//
@ -109,7 +109,7 @@ int Fl_Scrollbar::handle(int event) {
handle_release();
return 1;
case FL_PUSH:
take_focus();
if (Fl::visible_focus()) take_focus();
if (pushed_) return 1;
if (area != 8) pushed_ = area;
if (pushed_) {
@ -129,8 +129,10 @@ int Fl_Scrollbar::handle(int event) {
return 1;
case FL_FOCUS :
case FL_UNFOCUS :
damage(FL_DAMAGE_ALL);
return 1;
if (Fl::visible_focus()) {
redraw();
return 1;
} else return 0;
case FL_SHORTCUT:
case FL_KEYBOARD: {
int v = value();
@ -244,5 +246,5 @@ Fl_Scrollbar::Fl_Scrollbar(int X, int Y, int W, int H, const char* L)
}
//
// End of "$Id: Fl_Scrollbar.cxx,v 1.7.2.14.2.3 2001/10/29 03:44:32 easysw Exp $".
// End of "$Id: Fl_Scrollbar.cxx,v 1.7.2.14.2.4 2001/11/03 19:24:22 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Slider.cxx,v 1.8.2.10.2.2 2001/10/18 23:41:04 easysw Exp $"
// "$Id: Fl_Slider.cxx,v 1.8.2.10.2.3 2001/11/03 19:24:22 easysw Exp $"
//
// Slider widget for the Fast Light Tool Kit (FLTK).
//
@ -181,7 +181,7 @@ int Fl_Slider::handle(int event, int x, int y, int w, int h) {
switch (event) {
case FL_PUSH:
if (!Fl::event_inside(x, y, w, h)) return 0;
take_focus();
if (Fl::visible_focus()) take_focus();
handle_push();
case FL_DRAG: {
@ -270,8 +270,10 @@ int Fl_Slider::handle(int event, int x, int y, int w, int h) {
break;
case FL_FOCUS :
case FL_UNFOCUS :
damage(FL_DAMAGE_ALL);
return 1;
if (Fl::visible_focus()) {
redraw();
return 1;
} else return 0;
case FL_ENTER :
case FL_LEAVE :
return 1;
@ -289,5 +291,5 @@ int Fl_Slider::handle(int event) {
}
//
// End of "$Id: Fl_Slider.cxx,v 1.8.2.10.2.2 2001/10/18 23:41:04 easysw Exp $".
// End of "$Id: Fl_Slider.cxx,v 1.8.2.10.2.3 2001/11/03 19:24:22 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Tabs.cxx,v 1.6.2.10.2.1 2001/08/05 15:34:28 easysw Exp $"
// "$Id: Fl_Tabs.cxx,v 1.6.2.10.2.2 2001/11/03 19:24:22 easysw Exp $"
//
// Tab widget for the Fast Light Tool Kit (FLTK).
//
@ -138,7 +138,7 @@ int Fl_Tabs::handle(int event) {
} else {
if (Fl::event_y() < y()+h()+H) goto DEFAULT;
}}
take_focus();
if (Fl::visible_focus()) take_focus();
case FL_DRAG:
case FL_RELEASE:
o = which(Fl::event_x(), Fl::event_y());
@ -147,8 +147,10 @@ int Fl_Tabs::handle(int event) {
return 1;
case FL_FOCUS:
case FL_UNFOCUS:
redraw();
return 1;
if (Fl::visible_focus()) {
redraw();
return 1;
} else return 0;
case FL_KEYBOARD:
switch (Fl::event_key()) {
case FL_Left:
@ -309,5 +311,5 @@ Fl_Tabs::Fl_Tabs(int X,int Y,int W, int H, const char *l) :
}
//
// End of "$Id: Fl_Tabs.cxx,v 1.6.2.10.2.1 2001/08/05 15:34:28 easysw Exp $".
// End of "$Id: Fl_Tabs.cxx,v 1.6.2.10.2.2 2001/11/03 19:24:22 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_arg.cxx,v 1.5.2.8 2001/03/20 18:02:52 spitzak Exp $"
// "$Id: Fl_arg.cxx,v 1.5.2.8.2.1 2001/11/03 19:24:22 easysw Exp $"
//
// Optional argument initialization code for the Fast Light Tool Kit (FLTK).
//
@ -83,6 +83,14 @@ int Fl::arg(int argc, char **argv, int &i) {
fl_show_iconic = 1;
i++;
return 1;
} else if (match(s, "kbd")) {
Fl::visible_focus(1);
i++;
return 1;
} else if (match(s, "nokbd")) {
Fl::visible_focus(0);
i++;
return 1;
}
const char *v = argv[i+1];
@ -357,5 +365,5 @@ int XParseGeometry(const char* string, int* x, int* y,
#endif // ifdef WIN32
//
// End of "$Id: Fl_arg.cxx,v 1.5.2.8 2001/03/20 18:02:52 spitzak Exp $".
// End of "$Id: Fl_arg.cxx,v 1.5.2.8.2.1 2001/11/03 19:24:22 easysw Exp $".
//