Clean up keyboard focus navigation.
This commit is contained in:
parent
035474e17c
commit
424b1b9b8f
|
@ -22,23 +22,23 @@
|
||||||
/* Just like an Fl_Input, except that when not being edited it
|
/* Just like an Fl_Input, except that when not being edited it
|
||||||
* displays just like a label. */
|
* displays just like a label. */
|
||||||
|
|
||||||
|
#include <FL/Fl.H>
|
||||||
|
|
||||||
class Fl_Sometimes_Input : public Fl_Input
|
class Fl_Sometimes_Input : public Fl_Input
|
||||||
{
|
{
|
||||||
|
|
||||||
bool _editing;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Fl_Sometimes_Input ( int X, int Y, int W, int H, const char *L=0 )
|
Fl_Sometimes_Input ( int X, int Y, int W, int H, const char *L=0 )
|
||||||
: Fl_Input( X, Y, W, H, L )
|
: Fl_Input( X, Y, W, H, L )
|
||||||
{
|
{
|
||||||
_editing = false;
|
clear_visible_focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
draw ( void )
|
draw ( void )
|
||||||
{
|
{
|
||||||
if ( _editing )
|
if ( this == Fl::focus() )
|
||||||
Fl_Input::draw();
|
Fl_Input::draw();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -56,15 +56,15 @@ public:
|
||||||
switch ( m )
|
switch ( m )
|
||||||
{
|
{
|
||||||
case FL_FOCUS:
|
case FL_FOCUS:
|
||||||
_editing = true;
|
|
||||||
redraw();
|
redraw();
|
||||||
return 1;
|
return 1;
|
||||||
case FL_PUSH:
|
case FL_PUSH:
|
||||||
_editing = true;
|
set_visible_focus();
|
||||||
|
take_focus();
|
||||||
|
clear_visible_focus();
|
||||||
redraw();
|
redraw();
|
||||||
return r;
|
return r;
|
||||||
case FL_UNFOCUS:
|
case FL_UNFOCUS:
|
||||||
_editing = false;
|
|
||||||
|
|
||||||
if ( window() )
|
if ( window() )
|
||||||
window()->damage( FL_DAMAGE_EXPOSE, x(), y(), w(), h() );
|
window()->damage( FL_DAMAGE_EXPOSE, x(), y(), w(), h() );
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
int
|
int
|
||||||
test_press ( unsigned long e )
|
test_press ( unsigned long e )
|
||||||
{
|
{
|
||||||
|
if ( Fl::event_text()[0] )
|
||||||
((char *)Fl::event_text())[0] = '\0';
|
((char *)Fl::event_text())[0] = '\0';
|
||||||
|
|
||||||
if ( ! ( e & FL_SHIFT ) )
|
if ( ! ( e & FL_SHIFT ) )
|
||||||
|
|
|
@ -57,6 +57,8 @@ Sequence::init ( void )
|
||||||
box( FL_DOWN_BOX );
|
box( FL_DOWN_BOX );
|
||||||
color( FL_BACKGROUND_COLOR );
|
color( FL_BACKGROUND_COLOR );
|
||||||
align( FL_ALIGN_LEFT );
|
align( FL_ALIGN_LEFT );
|
||||||
|
|
||||||
|
// clear_visible_focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
Sequence::~Sequence ( )
|
Sequence::~Sequence ( )
|
||||||
|
@ -284,6 +286,10 @@ Sequence::handle ( int m )
|
||||||
|
|
||||||
switch ( 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:
|
case FL_NO_EVENT:
|
||||||
/* garbage from overlay window */
|
/* garbage from overlay window */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -950,6 +950,13 @@ Timeline::track_under ( int Y )
|
||||||
#include "FL/event_name.H"
|
#include "FL/event_name.H"
|
||||||
#include "FL/test_press.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
|
int
|
||||||
Timeline::handle ( int m )
|
Timeline::handle ( int m )
|
||||||
{
|
{
|
||||||
|
@ -959,8 +966,7 @@ Timeline::handle ( int m )
|
||||||
/* if ( m != FL_NO_EVENT ) */
|
/* if ( m != FL_NO_EVENT ) */
|
||||||
/* DMESSAGE( "%s", event_name( m ) ); */
|
/* DMESSAGE( "%s", event_name( m ) ); */
|
||||||
|
|
||||||
|
/* int r = Fl_Overlay_Window::handle( m ); */
|
||||||
int r = Fl_Overlay_Window::handle( m );
|
|
||||||
|
|
||||||
switch ( m )
|
switch ( m )
|
||||||
{
|
{
|
||||||
|
@ -1001,7 +1007,7 @@ Timeline::handle ( int m )
|
||||||
/* keep scrollbar from eating these. */
|
/* keep scrollbar from eating these. */
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return r;
|
return Fl_Overlay_Window::handle( m );
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1014,7 +1020,7 @@ Timeline::handle ( int m )
|
||||||
|
|
||||||
//Fl::focus( this );
|
//Fl::focus( this );
|
||||||
|
|
||||||
/* r = Fl_Overlay_Window::handle( m ); */
|
int r = Fl_Overlay_Window::handle( m );
|
||||||
|
|
||||||
if ( m != FL_RELEASE && r )
|
if ( m != FL_RELEASE && r )
|
||||||
return r;
|
return r;
|
||||||
|
|
|
@ -171,6 +171,7 @@ public:
|
||||||
|
|
||||||
void draw ( void );
|
void draw ( void );
|
||||||
void draw_overlay ( void );
|
void draw_overlay ( void );
|
||||||
|
int handle_scroll ( int m );
|
||||||
int handle ( int m );
|
int handle ( int m );
|
||||||
static void update_cb ( void *arg );
|
static void update_cb ( void *arg );
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,8 @@ Track::init ( void )
|
||||||
|
|
||||||
labeltype( FL_NO_LABEL );
|
labeltype( FL_NO_LABEL );
|
||||||
|
|
||||||
|
// clear_visible_focus();
|
||||||
|
|
||||||
Fl_Group::size( timeline->w(), height() );
|
Fl_Group::size( timeline->w(), height() );
|
||||||
|
|
||||||
Track *o = this;
|
Track *o = this;
|
||||||
|
@ -500,8 +502,6 @@ Track::handle ( int m )
|
||||||
}
|
}
|
||||||
case FL_PUSH:
|
case FL_PUSH:
|
||||||
{
|
{
|
||||||
Fl::event_key( 0 );
|
|
||||||
|
|
||||||
Logger log( this );
|
Logger log( this );
|
||||||
|
|
||||||
int X = Fl::event_x();
|
int X = Fl::event_x();
|
||||||
|
|
Loading…
Reference in New Issue