Mercurial > repos > blastem
changeset 1854:58b6f5d918f4
Minor improvements to keyboard navigation
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 25 Apr 2019 21:54:47 -0700 |
parents | 9b2acecf8124 |
children | 92532eb6986d |
files | nuklear_ui/blastem_nuklear.c nuklear_ui/nuklear.h |
diffstat | 2 files changed, 22 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/nuklear_ui/blastem_nuklear.c Wed Apr 24 20:46:35 2019 -0700 +++ b/nuklear_ui/blastem_nuklear.c Thu Apr 25 21:54:47 2019 -0700 @@ -2076,6 +2076,10 @@ .r = 255, .g = 128, .b = 0, .a = 255 }; context->style.checkbox.cursor_hover = context->style.checkbox.cursor_normal; + context->style.property.inc_button.text_hover = (struct nk_color){ + .r = 255, .g = 128, .b = 0, .a = 255 + }; + context->style.property.dec_button.text_hover = context->style.property.inc_button.text_hover; } static void context_created(void)
--- a/nuklear_ui/nuklear.h Wed Apr 24 20:46:35 2019 -0700 +++ b/nuklear_ui/nuklear.h Thu Apr 25 21:54:47 2019 -0700 @@ -16176,9 +16176,11 @@ if (style->draw_end) style->draw_end(out, style->userdata); int selected = in && in->selected_widget == in->widget_counter; + int enter_clicked; if (selected) { //prevent left/right buttons from activating when enter is pressed - in->selected_widget = -1; + enter_clicked = in->keyboard.keys[NK_KEY_ENTER].clicked; + in->keyboard.keys[NK_KEY_ENTER].clicked = 0; } /* execute left button */ if ( @@ -16211,7 +16213,7 @@ } } if (selected) { - in->selected_widget = in->widget_counter; + in->keyboard.keys[NK_KEY_ENTER].clicked = enter_clicked; } if (old != NK_PROPERTY_EDIT && (*state == NK_PROPERTY_EDIT)) { /* property has been activated so setup buffer */ @@ -20698,9 +20700,13 @@ if (!state) return 0; in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input; - return nk_do_button_text(&ctx->last_widget_state, &win->buffer, bounds, + int ret = nk_do_button_text(&ctx->last_widget_state, &win->buffer, bounds, title, len, style->text_alignment, ctx->button_behavior, style, in, ctx->style.font); + if (ctx->last_widget_state & NK_WIDGET_STATE_ENTERED) { + ctx->input.selected_widget = ctx->input.widget_counter; + } + return ret; } NK_API int @@ -20751,6 +20757,9 @@ ret = nk_do_button(&ctx->last_widget_state, &win->buffer, bounds, &button, in, ctx->button_behavior, &content); nk_draw_button(&win->buffer, &bounds, ctx->last_widget_state, &button); + if (ctx->last_widget_state & NK_WIDGET_STATE_ENTERED) { + ctx->input.selected_widget = ctx->input.widget_counter; + } return ret; } @@ -20776,8 +20785,12 @@ state = nk_keynav_widget(&bounds, ctx); if (!state) return 0; in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input; - return nk_do_button_symbol(&ctx->last_widget_state, &win->buffer, bounds, + int ret = nk_do_button_symbol(&ctx->last_widget_state, &win->buffer, bounds, symbol, ctx->button_behavior, style, in, ctx->style.font); + if (ctx->last_widget_state & NK_WIDGET_STATE_ENTERED) { + ctx->input.selected_widget = ctx->input.widget_counter; + } + return ret; } NK_API int @@ -21552,6 +21565,7 @@ ctx->input.mouse.grab = nk_true; ctx->input.mouse.grabbed = nk_true; } + ctx->input.selected_widget = ctx->input.widget_counter; } /* check if previously active property is now inactive */ if (*state == NK_PROPERTY_DEFAULT && old_state != NK_PROPERTY_DEFAULT) {