diff --git a/docs/changelog.txt b/docs/changelog.txt index da5a2d4d7c..cd86e6eec9 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -76,6 +76,7 @@ Template for new versions: - `timestream`: deal properly with units who have breathing difficulties - `stocks`: overlay now resets scroll position when collapsing categories so the item list is no longer left blank and unscrollable - Fixed persistent site data API (``dfhack.persistent.saveSiteData``/``getSiteData``) failing on newly reclaimed fortresses until the first save +- `overlay`: overlay hotkeys no longer steal typed characters while the game is capturing text input, e.g. when renaming a building ## Misc Improvements - Added ``Coord2d`` and ``Coord3d`` C++ templates, providing a standard set operations for 2-tuples and 3-tuples of any numeric type diff --git a/plugins/lua/overlay.lua b/plugins/lua/overlay.lua index cdfaac89e1..730a0bab40 100644 --- a/plugins/lua/overlay.lua +++ b/plugins/lua/overlay.lua @@ -530,7 +530,25 @@ local function _feed_viewscreen_widgets(vs_name, vs, keys) return false end +-- when the native UI is capturing text input (renaming a building, editing a +-- workshop job filter, etc.), overlay widgets must not consume keys, since +-- their bound hotkeys would otherwise steal typed characters (#5764) +local function is_native_text_entry_active() + local mi = df.global.game.main_interface + local vs = mi.view_sheets + return mi.entering_building_name or + vs.building_entering_nickname or + vs.unit_overview_entering_nickname or + vs.unit_overview_entering_profession_nickname or + vs.entering_building_job_filter or + vs.entering_gen_work_order_num or + vs.entering_wq_number +end + function feed_viewscreen_widgets(vs_name, vs, keys) + if is_native_text_entry_active() then + return false + end if not _feed_viewscreen_widgets(vs_name, vs, keys) and not _feed_viewscreen_widgets('all', nil, keys) then return false