Skip to content

Commit

Permalink
Fix ALT overriding text input
Browse files Browse the repository at this point in the history
  • Loading branch information
tonsa1 committed Jan 17, 2024
1 parent 057a6f3 commit ba5ce44
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 1 deletion.
42 changes: 42 additions & 0 deletions src/df/gfx/df_views.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,15 @@ df_eval_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_EvalW
}
}

// check if edit is still live and focus is on the same panel
if(ui_is_focus_active())
{
ui_set_focus_editing(ewv->input_editing);
}
if(ewv->input_editing && !ui_is_focus_active())
{
ui_unset_focus_editing();
}
//////////////////////////////
//- rjf: build ui
//
Expand Down Expand Up @@ -1538,6 +1547,7 @@ df_eval_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_EvalW
if(edit_end)
{
ewv->input_editing = 0;
ui_unset_focus_editing();
}

//////////////////////////////
Expand Down Expand Up @@ -2916,6 +2926,15 @@ DF_VIEW_UI_FUNCTION_DEF(Target)
}
}
}
// check if edit is still live and focus is on the same panel
if(ui_is_focus_active())
{
ui_set_focus_editing(tv->input_editing);
}
if(tv->input_editing && !ui_is_focus_active())
{
ui_unset_focus_editing();
}

//- rjf: build
Rng1S64 visible_row_range = {0};
Expand Down Expand Up @@ -3086,6 +3105,7 @@ DF_VIEW_UI_FUNCTION_DEF(Target)
if(edit_end)
{
tv->input_editing = 0;
ui_unset_focus_editing();
}
if(edit_submit)
{
Expand Down Expand Up @@ -3366,6 +3386,16 @@ DF_VIEW_UI_FUNCTION_DEF(FilePathMap)
}
}
}

// check if edit is still live and focus is on the same panel
if(ui_is_focus_active())
{
ui_set_focus_editing(fpms->input_editing);
}
if(fpms->input_editing && !ui_is_focus_active())
{
ui_unset_focus_editing();
}

//- rjf: build
DF_Handle commit_map = df_handle_zero();
Expand Down Expand Up @@ -3576,6 +3606,7 @@ DF_VIEW_UI_FUNCTION_DEF(FilePathMap)
if(edit_end)
{
fpms->input_editing = 0;
ui_unset_focus_editing();
}

//- rjf: move down one row if submitted
Expand Down Expand Up @@ -4154,6 +4185,16 @@ DF_VIEW_UI_FUNCTION_DEF(Modules)
edit_submit = 1;
}
}

// check if edit is still live and focus is on the same panel
if(ui_is_focus_active())
{
ui_set_focus_editing(mv->txt_editing);
}
if(mv->txt_editing && !ui_is_focus_active())
{
ui_unset_focus_editing();
}

//- rjf: build table
DF_Entity *commit_module = &df_g_nil_entity;
Expand Down Expand Up @@ -4311,6 +4352,7 @@ DF_VIEW_UI_FUNCTION_DEF(Modules)
if(edit_end)
{
mv->txt_editing = 0;
ui_unset_focus_editing();
}

//- rjf: selected num -> selected entity
Expand Down
17 changes: 16 additions & 1 deletion src/raddbg/raddbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,22 @@ update_and_render(OS_Handle repaint_window_handle, void *user_data)
{
next = event->next;
DF_Window *ws = df_window_from_os_handle(event->window);
if(ws == 0)

DF_CmdQueryRule query_rule = DF_CmdQueryRule_Null;
// check if focused panel has an active command query
{
DF_Panel *panel = ws->focused_panel;
if(!df_panel_is_nil(panel))
{
DF_View *view = df_selected_view_from_panel(panel);
if(!df_view_is_nil(view))
{
query_rule = view->cmd_spec->info.query_rule;
}
}
}

if(ws == 0 || ui_is_focus_editing() || query_rule != DF_CmdQueryRule_Null)
{
continue;
}
Expand Down
19 changes: 19 additions & 0 deletions src/ui/ui_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1720,6 +1720,18 @@ ui_unset_focus_hot(void)
ui_state->focus_hot_is_possible = 0;
}

internal void
ui_set_focus_editing(B32 check)
{
ui_state->focus_editing_is_set = check;
}

internal void
ui_unset_focus_editing(void)
{
ui_state->focus_editing_is_set = 0;
}

internal B32
ui_is_focus_active(void)
{
Expand Down Expand Up @@ -1762,6 +1774,13 @@ ui_is_focus_hot(void)
return result;
}

internal B32
ui_is_focus_editing(void)
{
B32 result = ui_state->focus_editing_is_set;
return result;
}

//- rjf: implicit auto-managed tree-based focus state

internal B32
Expand Down
5 changes: 5 additions & 0 deletions src/ui/ui_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ struct UI_State
B32 focus_hot_is_possible;
B32 focus_active_is_set;
B32 focus_active_is_possible;
B32 focus_editing_is_set;

//- rjf: build phase stacks
UI_StackDecls;
Expand Down Expand Up @@ -562,8 +563,12 @@ internal void ui_set_focus_active(B32 check);
internal void ui_unset_focus_active(void);
internal void ui_set_focus_hot(B32 check);
internal void ui_unset_focus_hot(void);
internal void ui_set_focus_editing(B32 check);
internal void ui_unset_focus_editing(void);
internal B32 ui_is_focus_active(void);
internal B32 ui_is_focus_hot(void);
internal B32 ui_is_focus_editing(void);


//- rjf: implicit auto-managed tree-based focus state
internal B32 ui_is_key_auto_focus_active(UI_Key key);
Expand Down

0 comments on commit ba5ce44

Please sign in to comment.