Clean up keyboard focus navigation.

This commit is contained in:
Jonathan Moore Liles 2008-05-26 22:32:35 -05:00
parent 035474e17c
commit 424b1b9b8f
6 changed files with 28 additions and 14 deletions

View File

@ -22,23 +22,23 @@
/* Just like an Fl_Input, except that when not being edited it
* displays just like a label. */
#include <FL/Fl.H>
class Fl_Sometimes_Input : public Fl_Input
{
bool _editing;
public:
Fl_Sometimes_Input ( int X, int Y, int W, int H, const char *L=0 )
: Fl_Input( X, Y, W, H, L )
{
_editing = false;
clear_visible_focus();
}
virtual void
draw ( void )
{
if ( _editing )
if ( this == Fl::focus() )
Fl_Input::draw();
else
{
@ -56,15 +56,15 @@ public:
switch ( m )
{
case FL_FOCUS:
_editing = true;
redraw();
return 1;
case FL_PUSH:
_editing = true;
set_visible_focus();
take_focus();
clear_visible_focus();
redraw();
return r;
case FL_UNFOCUS:
_editing = false;
if ( window() )
window()->damage( FL_DAMAGE_EXPOSE, x(), y(), w(), h() );

View File

@ -28,6 +28,7 @@
int
test_press ( unsigned long e )
{
if ( Fl::event_text()[0] )
((char *)Fl::event_text())[0] = '\0';
if ( ! ( e & FL_SHIFT ) )

View File

@ -57,6 +57,8 @@ Sequence::init ( void )
box( FL_DOWN_BOX );
color( FL_BACKGROUND_COLOR );
align( FL_ALIGN_LEFT );
// clear_visible_focus();
}
Sequence::~Sequence ( )
@ -284,6 +286,10 @@ Sequence::handle ( int m )
switch ( m )
{
case FL_KEYBOARD:
/* this is a hack to override FLTK's use of arrow keys for
* focus navigation */
return timeline->handle_scroll( m );
case FL_NO_EVENT:
/* garbage from overlay window */
return 0;

View File

@ -950,6 +950,13 @@ Timeline::track_under ( int Y )
#include "FL/event_name.H"
#include "FL/test_press.H"
/** give the scrollbars a shot at events */
int
Timeline::handle_scroll ( int m )
{
return hscroll->handle( m ) || vscroll->handle( m );
}
int
Timeline::handle ( int m )
{
@ -959,8 +966,7 @@ Timeline::handle ( int m )
/* if ( m != FL_NO_EVENT ) */
/* DMESSAGE( "%s", event_name( m ) ); */
int r = Fl_Overlay_Window::handle( m );
/* int r = Fl_Overlay_Window::handle( m ); */
switch ( m )
{
@ -1001,7 +1007,7 @@ Timeline::handle ( int m )
/* keep scrollbar from eating these. */
return 0;
default:
return r;
return Fl_Overlay_Window::handle( m );
}
return 0;
@ -1014,7 +1020,7 @@ Timeline::handle ( int m )
//Fl::focus( this );
/* r = Fl_Overlay_Window::handle( m ); */
int r = Fl_Overlay_Window::handle( m );
if ( m != FL_RELEASE && r )
return r;

View File

@ -171,6 +171,7 @@ public:
void draw ( void );
void draw_overlay ( void );
int handle_scroll ( int m );
int handle ( int m );
static void update_cb ( void *arg );

View File

@ -124,6 +124,8 @@ Track::init ( void )
labeltype( FL_NO_LABEL );
// clear_visible_focus();
Fl_Group::size( timeline->w(), height() );
Track *o = this;
@ -500,8 +502,6 @@ Track::handle ( int m )
}
case FL_PUSH:
{
Fl::event_key( 0 );
Logger log( this );
int X = Fl::event_x();