Make the focus follow the last selected item for multiselect listboxes.

This commit is contained in:
Gerard Patel 2000-07-09 12:18:14 +00:00 committed by Alexandre Julliard
parent 2cbda2ef92
commit 2ffbb31e3a
1 changed files with 26 additions and 27 deletions

View File

@ -1229,6 +1229,31 @@ static void LISTBOX_MakeItemVisible( WND *wnd, LB_DESCR *descr, INT index,
LISTBOX_SetTopItem( wnd, descr, top, TRUE );
}
/***********************************************************************
* LISTBOX_SetCaretIndex
*
* NOTES
* index must be between 0 and descr->nb_items-1, or LB_ERR is returned.
*
*/
static LRESULT LISTBOX_SetCaretIndex( WND *wnd, LB_DESCR *descr, INT index,
BOOL fully_visible )
{
INT oldfocus = descr->focus_item;
if ((index < 0) || (index >= descr->nb_items)) return LB_ERR;
if (index == oldfocus) return LB_OKAY;
descr->focus_item = index;
if ((oldfocus != -1) && descr->caret_on && (descr->in_focus))
LISTBOX_RepaintItem( wnd, descr, oldfocus, ODA_FOCUS );
LISTBOX_MakeItemVisible( wnd, descr, index, fully_visible );
if (descr->caret_on && (descr->in_focus))
LISTBOX_RepaintItem( wnd, descr, index, ODA_FOCUS );
return LB_OKAY;
}
/***********************************************************************
* LISTBOX_SelectItemRange
@ -1258,6 +1283,7 @@ static LRESULT LISTBOX_SelectItemRange( WND *wnd, LB_DESCR *descr, INT first,
descr->items[i].selected = TRUE;
LISTBOX_RepaintItem( wnd, descr, i, ODA_SELECT );
}
LISTBOX_SetCaretIndex( wnd, descr, last, TRUE );
}
else /* Turn selection off */
{
@ -1271,33 +1297,6 @@ static LRESULT LISTBOX_SelectItemRange( WND *wnd, LB_DESCR *descr, INT first,
return LB_OKAY;
}
/***********************************************************************
* LISTBOX_SetCaretIndex
*
* NOTES
* index must be between 0 and descr->nb_items-1, or LB_ERR is returned.
*
*/
static LRESULT LISTBOX_SetCaretIndex( WND *wnd, LB_DESCR *descr, INT index,
BOOL fully_visible )
{
INT oldfocus = descr->focus_item;
if ((index < 0) || (index >= descr->nb_items)) return LB_ERR;
if (index == oldfocus) return LB_OKAY;
descr->focus_item = index;
if ((oldfocus != -1) && descr->caret_on && (descr->in_focus))
LISTBOX_RepaintItem( wnd, descr, oldfocus, ODA_FOCUS );
LISTBOX_MakeItemVisible( wnd, descr, index, fully_visible );
if (descr->caret_on && (descr->in_focus))
LISTBOX_RepaintItem( wnd, descr, index, ODA_FOCUS );
return LB_OKAY;
}
/***********************************************************************
* LISTBOX_SetSelection
*/