From 51050b38d82ca53bb71c85d2031f9777e6dd373e Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Sun, 5 Aug 2001 14:00:15 +0000 Subject: Keyboard nav for valuators. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1555 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Counter.cxx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/Fl_Counter.cxx') diff --git a/src/Fl_Counter.cxx b/src/Fl_Counter.cxx index 06f26ff30..93f8c0e3f 100644 --- a/src/Fl_Counter.cxx +++ b/src/Fl_Counter.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Counter.cxx,v 1.8.2.3 2001/01/22 15:13:39 easysw Exp $" +// "$Id: Fl_Counter.cxx,v 1.8.2.3.2.1 2001/08/05 14:00:15 easysw Exp $" // // Counter widget for the Fast Light Tool Kit (FLTK). // @@ -59,6 +59,7 @@ void Fl_Counter::draw() { fl_color(active_r() ? textcolor() : inactive(textcolor())); char str[128]; format(str); fl_draw(str, xx[0], y(), ww[0], h(), FL_ALIGN_CENTER); + if (Fl::focus() == this) draw_focus(boxtype[0], xx[0], y(), ww[0], h()); if (!(damage()&FL_DAMAGE_ALL)) return; // only need to redraw text if (active_r()) @@ -130,6 +131,7 @@ int Fl_Counter::handle(int event) { handle_release(); return 1; case FL_PUSH: + take_focus(); handle_push(); case FL_DRAG: i = calc_mouseobj(); @@ -141,6 +143,22 @@ int Fl_Counter::handle(int event) { redraw(); } return 1; + case FL_KEYBOARD : + switch (Fl::event_key()) { + case FL_Left: + handle_drag(clamp(increment(value(),-1))); + return 1; + case FL_Right: + handle_drag(clamp(increment(value(),1))); + return 1; + default: + return 0; + } + break; + case FL_FOCUS : + case FL_UNFOCUS : + damage(FL_DAMAGE_ALL); + return 1; default: return 0; } @@ -165,5 +183,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 2001/01/22 15:13:39 easysw Exp $". +// End of "$Id: Fl_Counter.cxx,v 1.8.2.3.2.1 2001/08/05 14:00:15 easysw Exp $". // -- cgit v1.2.3