[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);
|
static int toolkit_keyEvent(SDL_Event* event);
|
||||||
// Focus.
|
// Focus.
|
||||||
static void toolkit_nextFocus(void);
|
static void toolkit_nextFocus(void);
|
||||||
|
static int toolkit_isFocusable(Widget* wgt);
|
||||||
static void toolkit_triggerFocus(void);
|
static void toolkit_triggerFocus(void);
|
||||||
static Widget* toolkit_getFocus(void);
|
static Widget* toolkit_getFocus(void);
|
||||||
static void toolkit_listScroll(Widget* wgt, int direction);
|
static void toolkit_listScroll(Widget* wgt, int direction);
|
||||||
@ -791,6 +792,8 @@ static void toolkit_mouseEvent(SDL_Event* event) {
|
|||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
wgt->status = WIDGET_STATUS_MOUSEDOWN;
|
wgt->status = WIDGET_STATUS_MOUSEDOWN;
|
||||||
|
|
||||||
|
if(toolkit_isFocusable(wgt))
|
||||||
w->focus = i;
|
w->focus = i;
|
||||||
|
|
||||||
if(wgt->type == WIDGET_LIST)
|
if(wgt->type == WIDGET_LIST)
|
||||||
@ -899,13 +902,24 @@ static void toolkit_nextFocus(void) {
|
|||||||
else if(wdw->focus >= wdw->nwidgets)
|
else if(wdw->focus >= wdw->nwidgets)
|
||||||
wdw->focus = -1;
|
wdw->focus = -1;
|
||||||
else if((++wdw->focus+1) && // Just increment.
|
else if((++wdw->focus+1) && // Just increment.
|
||||||
((wdw->widgets[wdw->focus].type == WIDGET_BUTTON) ||
|
toolkit_isFocusable(&wdw->widgets[wdw->focus]))
|
||||||
(wdw->widgets[wdw->focus].type == WIDGET_LIST)))
|
|
||||||
return;
|
return;
|
||||||
else
|
else
|
||||||
toolkit_nextFocus();
|
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) {
|
static void toolkit_triggerFocus(void) {
|
||||||
Window* wdw;
|
Window* wdw;
|
||||||
Widget* wgt;
|
Widget* wgt;
|
||||||
|
Loading…
Reference in New Issue
Block a user