[Add] You can no longer focus unfocusable widgets.
This commit is contained in:
parent
f7bff6f341
commit
01a0324e79
@ -90,6 +90,7 @@ static void toolkit_mouseEvent(SDL_Event* event);
|
||||
static int toolkit_keyEvent(SDL_Event* event);
|
||||
// Focus.
|
||||
static void toolkit_nextFocus(void);
|
||||
static int toolkit_isFocusable(Widget* wgt);
|
||||
static void toolkit_triggerFocus(void);
|
||||
static Widget* toolkit_getFocus(void);
|
||||
static void toolkit_listScroll(Widget* wgt, int direction);
|
||||
@ -791,7 +792,9 @@ static void toolkit_mouseEvent(SDL_Event* event) {
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
wgt->status = WIDGET_STATUS_MOUSEDOWN;
|
||||
w->focus = i;
|
||||
|
||||
if(toolkit_isFocusable(wgt))
|
||||
w->focus = i;
|
||||
|
||||
if(wgt->type == WIDGET_LIST)
|
||||
toolkit_listFocus(wgt, x-wgt->x, y-wgt->y);
|
||||
@ -899,13 +902,24 @@ static void toolkit_nextFocus(void) {
|
||||
else if(wdw->focus >= wdw->nwidgets)
|
||||
wdw->focus = -1;
|
||||
else if((++wdw->focus+1) && // Just increment.
|
||||
((wdw->widgets[wdw->focus].type == WIDGET_BUTTON) ||
|
||||
(wdw->widgets[wdw->focus].type == WIDGET_LIST)))
|
||||
toolkit_isFocusable(&wdw->widgets[wdw->focus]))
|
||||
return;
|
||||
else
|
||||
toolkit_nextFocus();
|
||||
}
|
||||
|
||||
static int toolkit_isFocusable(Widget* wgt) {
|
||||
if(wgt == NULL) return 0;
|
||||
|
||||
switch(wgt->type) {
|
||||
case WIDGET_BUTTON:
|
||||
case WIDGET_LIST:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void toolkit_triggerFocus(void) {
|
||||
Window* wdw;
|
||||
Widget* wgt;
|
||||
|
Loading…
Reference in New Issue
Block a user