# HG changeset patch # User Michael Pavone # Date 1556254487 25200 # Node ID 58b6f5d918f4e1220b48fb4ab40acbc1cc4fe2f9 # Parent 9b2acecf8124ef6d46da77efe10af2618ae67aa6 Minor improvements to keyboard navigation diff -r 9b2acecf8124 -r 58b6f5d918f4 nuklear_ui/blastem_nuklear.c --- 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) diff -r 9b2acecf8124 -r 58b6f5d918f4 nuklear_ui/nuklear.h --- 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) {