mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
on keyDown, look at what keyUp will do and, if nothing, don't handle
the event. This lets focus transfer work as before there was keyDown.
This commit is contained in:
parent
e6ba8c872c
commit
f329966a8a
5 changed files with 75 additions and 44 deletions
|
@ -1,6 +1,6 @@
|
|||
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 1997 - 2006 by Eric House (xwords@eehouse.org). All rights
|
||||
* Copyright 1997 - 2007 by Eric House (xwords@eehouse.org). All rights
|
||||
* reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -123,7 +123,7 @@ static XP_Bool moveKeyTileToBoard( BoardCtxt* board, XP_Key cursorKey,
|
|||
|
||||
#ifdef KEYBOARD_NAV
|
||||
static XP_Bool board_moveCursor( BoardCtxt* board, XP_Key cursorKey,
|
||||
XP_Bool* up );
|
||||
XP_Bool preflightOnly, XP_Bool* up );
|
||||
static XP_Bool invalFocusOwner( BoardCtxt* board );
|
||||
#endif
|
||||
#ifdef XWFEATURE_SEARCHLIMIT
|
||||
|
@ -2584,7 +2584,45 @@ focusToCoords( BoardCtxt* board, XP_U16* xp, XP_U16* yp )
|
|||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
} /* focusToCoords */
|
||||
|
||||
/* The focus keys are special because they can cause focus to leave one object
|
||||
* and move to another (which the platform needs to be involved with). On
|
||||
* palm, that only works if the keyDown handler claims not to have handled the
|
||||
* event. So we must preflight, determining if the keyUp handler will handle
|
||||
* the event should it get to it. If it wouldn't, then the platform wants a
|
||||
* chance not to generate a keyUp event at all.
|
||||
*/
|
||||
static XP_Bool
|
||||
handleFocusKeyUp( BoardCtxt* board, XP_Key key, XP_Bool preflightOnly,
|
||||
XP_Bool* pHandled )
|
||||
{
|
||||
XP_Bool redraw = XP_FALSE;
|
||||
if ( board->focusHasDived ) {
|
||||
XP_Bool up = XP_FALSE;
|
||||
if ( board->focussed == OBJ_BOARD ) {
|
||||
redraw = board_moveCursor( board, flipKey( key, board->isFlipped ),
|
||||
preflightOnly, &up );
|
||||
} else if ( board->focussed == OBJ_SCORE ) {
|
||||
redraw = moveScoreCursor( board, key, preflightOnly, &up );
|
||||
} else if ( board->focussed == OBJ_TRAY ) {
|
||||
redraw = tray_moveCursor( board, key, preflightOnly, &up );
|
||||
}
|
||||
if ( up ) {
|
||||
if ( !preflightOnly ) {
|
||||
invalFocusOwner( board );
|
||||
board->focusHasDived = XP_FALSE;
|
||||
invalFocusOwner( board );
|
||||
}
|
||||
} else {
|
||||
*pHandled = redraw;
|
||||
}
|
||||
} else {
|
||||
/* Do nothing. We don't handle transition among top-level
|
||||
focussed objects. Platform must. */
|
||||
}
|
||||
return redraw;
|
||||
} /* handleFocusKeyUp */
|
||||
|
||||
XP_Bool
|
||||
board_handleKeyDown( BoardCtxt* board, XP_Key key, XP_Bool* pHandled )
|
||||
|
@ -2592,14 +2630,17 @@ board_handleKeyDown( BoardCtxt* board, XP_Key key, XP_Bool* pHandled )
|
|||
XP_Bool draw = XP_FALSE;
|
||||
XP_U16 x, y;
|
||||
|
||||
*pHandled = XP_FALSE;
|
||||
|
||||
if ( key == XP_RETURN_KEY ) {
|
||||
if ( focusToCoords( board, &x, &y ) ) {
|
||||
draw = handleLikeDown( board, board->focussed, x, y );
|
||||
*pHandled = draw;
|
||||
}
|
||||
} else if ( board->focussed != OBJ_NONE ) {
|
||||
draw = handleFocusKeyUp( board, key, XP_TRUE, pHandled ) || draw;
|
||||
}
|
||||
|
||||
*pHandled = (board->focussed != OBJ_NONE) && board->focusHasDived;
|
||||
|
||||
return draw;
|
||||
}
|
||||
|
||||
|
@ -2636,28 +2677,7 @@ board_handleKeyUp( BoardCtxt* board, XP_Key key, XP_Bool* pHandled )
|
|||
case XP_CURSOR_KEY_ALTLEFT:
|
||||
case XP_CURSOR_KEY_RIGHT:
|
||||
case XP_CURSOR_KEY_ALTRIGHT:
|
||||
if ( board->focusHasDived ) {
|
||||
XP_Bool up = XP_FALSE;
|
||||
if ( board->focussed == OBJ_BOARD ) {
|
||||
redraw = board_moveCursor( board,
|
||||
flipKey( key, board->isFlipped ),
|
||||
&up );
|
||||
} else if ( board->focussed == OBJ_SCORE ) {
|
||||
redraw = moveScoreCursor( board, key, &up );
|
||||
} else if ( board->focussed == OBJ_TRAY ) {
|
||||
redraw = tray_moveCursor( board, key, &up );
|
||||
}
|
||||
if ( up ) {
|
||||
invalFocusOwner( board );
|
||||
board->focusHasDived = XP_FALSE;
|
||||
invalFocusOwner( board );
|
||||
} else {
|
||||
handled = redraw;//XP_TRUE;
|
||||
}
|
||||
} else {
|
||||
/* Do nothing. We don't handle transition among top-level
|
||||
focussed objects. Platform must. */
|
||||
}
|
||||
redraw = handleFocusKeyUp( board, key, XP_FALSE, &handled );
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
@ -2932,7 +2952,8 @@ stripAlt( XP_Key key, XP_Bool* wasAlt )
|
|||
} /* stripAlt */
|
||||
|
||||
static XP_Bool
|
||||
board_moveCursor( BoardCtxt* board, XP_Key cursorKey, XP_Bool* up )
|
||||
board_moveCursor( BoardCtxt* board, XP_Key cursorKey, XP_Bool preflightOnly,
|
||||
XP_Bool* up )
|
||||
{
|
||||
BdCursorLoc loc = board->bdCursor[board->selPlayer];
|
||||
XP_U16 col = loc.col;
|
||||
|
@ -2944,7 +2965,7 @@ board_moveCursor( BoardCtxt* board, XP_Key cursorKey, XP_Bool* up )
|
|||
|
||||
changed = figureNextLoc( board, cursorKey, XP_FALSE, altSet,
|
||||
&col, &row, up );
|
||||
if ( changed ) {
|
||||
if ( changed && !preflightOnly ) {
|
||||
invalCell( board, loc.col, loc.row );
|
||||
invalCell( board, col, row );
|
||||
loc.col = col;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 1997 - 2000 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
* Copyright 1997 - 2007 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -201,7 +201,8 @@ void board_selectPlayer( BoardCtxt* board, XP_U16 newPlayer );
|
|||
|
||||
#ifdef KEYBOARD_NAV
|
||||
XP_Key flipKey( XP_Key key, XP_Bool flip );
|
||||
XP_Bool tray_moveCursor( BoardCtxt* board, XP_Key cursorKey, XP_Bool* up );
|
||||
XP_Bool tray_moveCursor( BoardCtxt* board, XP_Key cursorKey,
|
||||
XP_Bool preflightOnly, XP_Bool* up );
|
||||
XP_Bool tray_keyAction( BoardCtxt* board );
|
||||
DrawFocusState dfsFor( BoardCtxt* board, BoardObjectType obj );
|
||||
void shiftFocusUp( BoardCtxt* board, XP_Key key );
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 1997 - 2006 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
* Copyright 1997 - 2007 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -281,7 +281,8 @@ handlePenUpScore( BoardCtxt* board, XP_U16 x, XP_U16 y )
|
|||
|
||||
#ifdef KEYBOARD_NAV
|
||||
XP_Bool
|
||||
moveScoreCursor( BoardCtxt* board, XP_Key key, XP_Bool* pUp )
|
||||
moveScoreCursor( BoardCtxt* board, XP_Key key, XP_Bool preflightOnly,
|
||||
XP_Bool* pUp )
|
||||
{
|
||||
XP_Bool result = XP_TRUE;
|
||||
XP_U16 nPlayers = board->gi->nPlayers;
|
||||
|
@ -309,7 +310,7 @@ moveScoreCursor( BoardCtxt* board, XP_Key key, XP_Bool* pUp )
|
|||
}
|
||||
if ( !up && ((scoreCursorLoc < 0) || (scoreCursorLoc >= nPlayers)) ) {
|
||||
up = XP_TRUE;
|
||||
} else {
|
||||
} else if ( !preflightOnly ) {
|
||||
board->scoreCursorLoc = scoreCursorLoc;
|
||||
board->scoreBoardInvalid = XP_TRUE;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 1997 - 2006 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
* Copyright 1997 - 2007 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -31,7 +31,8 @@ XP_Bool handlePenUpScore( BoardCtxt* board, XP_U16 x, XP_U16 y );
|
|||
#endif
|
||||
|
||||
#ifdef KEYBOARD_NAV
|
||||
XP_Bool moveScoreCursor( BoardCtxt* board, XP_Key key, XP_Bool* up );
|
||||
XP_Bool moveScoreCursor( BoardCtxt* board, XP_Key key, XP_Bool preflightOnly,
|
||||
XP_Bool* up );
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 1997 - 2006 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
* Copyright 1997 - 2007 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -638,12 +638,14 @@ board_juggleTray( BoardCtxt* board )
|
|||
|
||||
#ifdef KEYBOARD_NAV
|
||||
XP_Bool
|
||||
tray_moveCursor( BoardCtxt* board, XP_Key cursorKey, XP_Bool* pUp )
|
||||
tray_moveCursor( BoardCtxt* board, XP_Key cursorKey, XP_Bool preflightOnly,
|
||||
XP_Bool* pUp )
|
||||
{
|
||||
XP_Bool draw = XP_FALSE;
|
||||
XP_Bool up = XP_FALSE;
|
||||
XP_U16 selPlayer = board->selPlayer;
|
||||
XP_S16 pos;
|
||||
TileBit what = 0;
|
||||
|
||||
switch ( cursorKey ) {
|
||||
case XP_CURSOR_KEY_UP:
|
||||
|
@ -657,12 +659,12 @@ tray_moveCursor( BoardCtxt* board, XP_Key cursorKey, XP_Bool* pUp )
|
|||
etc. */
|
||||
case XP_CURSOR_KEY_ALTRIGHT:
|
||||
case XP_CURSOR_KEY_ALTLEFT:
|
||||
draw = board_moveDivider( board, cursorKey == XP_CURSOR_KEY_ALTRIGHT );
|
||||
draw = preflightOnly
|
||||
|| board_moveDivider( board, cursorKey == XP_CURSOR_KEY_ALTRIGHT );
|
||||
break;
|
||||
case XP_CURSOR_KEY_RIGHT:
|
||||
case XP_CURSOR_KEY_LEFT:
|
||||
board_invalTrayTiles( board, 1 << board->trayCursorLoc[selPlayer] );
|
||||
|
||||
what = what | (1 << board->trayCursorLoc[selPlayer]);
|
||||
pos = board->trayCursorLoc[selPlayer];
|
||||
/* Loop in order to skip all empty tile slots but one */
|
||||
for ( ; ; ) {
|
||||
|
@ -680,12 +682,17 @@ tray_moveCursor( BoardCtxt* board, XP_Key cursorKey, XP_Bool* pUp )
|
|||
continue;
|
||||
}
|
||||
}
|
||||
board->trayCursorLoc[selPlayer] = pos;
|
||||
board_invalTrayTiles( board, 1 << pos );
|
||||
if ( !preflightOnly ) {
|
||||
board->trayCursorLoc[selPlayer] = pos;
|
||||
what = what | (1 << pos);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
board_invalTrayTiles( board, 1 << board->trayCursorLoc[selPlayer] );
|
||||
if ( !preflightOnly ) {
|
||||
what = what | (1 << board->trayCursorLoc[selPlayer]);
|
||||
board_invalTrayTiles( board, what );
|
||||
}
|
||||
draw = XP_TRUE;
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue