mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
InputText: Fixed not being able to use CTRL+Tab while an InputText() using Tab for completion or textinput is active.
(regresion from 1.89) + removed unnecessary if block in NavProcessItem()
This commit is contained in:
parent
3b2f617652
commit
a322122f74
@ -59,6 +59,8 @@ Other changes:
|
|||||||
frame time > repeat rate. Triggering a new move request on the same frame as a move
|
frame time > repeat rate. Triggering a new move request on the same frame as a move
|
||||||
result lead to an incorrect calculation and loss of navigation id. (#6171)
|
result lead to an incorrect calculation and loss of navigation id. (#6171)
|
||||||
- IO: Lifted constraint to call io.AddEventXXX functions from current context. (#4921, #5856, #6199)
|
- IO: Lifted constraint to call io.AddEventXXX functions from current context. (#4921, #5856, #6199)
|
||||||
|
- InputText: Fixed not being able to use CTRL+Tab while an InputText() using Tab
|
||||||
|
for completion or textinput is active (regresion from 1.89).
|
||||||
- Drag and Drop: Fixed handling of overlapping targets when smaller one is submitted
|
- Drag and Drop: Fixed handling of overlapping targets when smaller one is submitted
|
||||||
before and can accept the same data type. (#6183).
|
before and can accept the same data type. (#6183).
|
||||||
- Drag and Drop: Clear drag and drop state as soon as delivery is accepted in order to
|
- Drag and Drop: Clear drag and drop state as soon as delivery is accepted in order to
|
||||||
|
19
imgui.cpp
19
imgui.cpp
@ -10758,18 +10758,15 @@ static void ImGui::NavProcessItem()
|
|||||||
else if ((g.NavId != id || (g.NavMoveFlags & ImGuiNavMoveFlags_AllowCurrentNavId)) && !(item_flags & ImGuiItemFlags_Disabled))
|
else if ((g.NavId != id || (g.NavMoveFlags & ImGuiNavMoveFlags_AllowCurrentNavId)) && !(item_flags & ImGuiItemFlags_Disabled))
|
||||||
{
|
{
|
||||||
ImGuiNavItemData* result = (window == g.NavWindow) ? &g.NavMoveResultLocal : &g.NavMoveResultOther;
|
ImGuiNavItemData* result = (window == g.NavWindow) ? &g.NavMoveResultLocal : &g.NavMoveResultOther;
|
||||||
if (!is_tabbing)
|
if (NavScoreItem(result))
|
||||||
{
|
NavApplyItemToResult(result);
|
||||||
if (NavScoreItem(result))
|
|
||||||
NavApplyItemToResult(result);
|
|
||||||
|
|
||||||
// Features like PageUp/PageDown need to maintain a separate score for the visible set of items.
|
// Features like PageUp/PageDown need to maintain a separate score for the visible set of items.
|
||||||
const float VISIBLE_RATIO = 0.70f;
|
const float VISIBLE_RATIO = 0.70f;
|
||||||
if ((g.NavMoveFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) && window->ClipRect.Overlaps(nav_bb))
|
if ((g.NavMoveFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) && window->ClipRect.Overlaps(nav_bb))
|
||||||
if (ImClamp(nav_bb.Max.y, window->ClipRect.Min.y, window->ClipRect.Max.y) - ImClamp(nav_bb.Min.y, window->ClipRect.Min.y, window->ClipRect.Max.y) >= (nav_bb.Max.y - nav_bb.Min.y) * VISIBLE_RATIO)
|
if (ImClamp(nav_bb.Max.y, window->ClipRect.Min.y, window->ClipRect.Max.y) - ImClamp(nav_bb.Min.y, window->ClipRect.Min.y, window->ClipRect.Max.y) >= (nav_bb.Max.y - nav_bb.Min.y) * VISIBLE_RATIO)
|
||||||
if (NavScoreItem(&g.NavMoveResultLocalVisible))
|
if (NavScoreItem(&g.NavMoveResultLocalVisible))
|
||||||
NavApplyItemToResult(&g.NavMoveResultLocalVisible);
|
NavApplyItemToResult(&g.NavMoveResultLocalVisible);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4186,7 +4186,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
if (is_osx)
|
if (is_osx)
|
||||||
SetKeyOwner(ImGuiMod_Alt, id);
|
SetKeyOwner(ImGuiMod_Alt, id);
|
||||||
if (flags & (ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_AllowTabInput)) // Disable keyboard tabbing out as we will use the \t character.
|
if (flags & (ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_AllowTabInput)) // Disable keyboard tabbing out as we will use the \t character.
|
||||||
SetKeyOwner(ImGuiKey_Tab, id);
|
SetShortcutRouting(ImGuiKey_Tab, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have an edge case if ActiveId was set through another widget (e.g. widget being swapped), clear id immediately (don't wait until the end of the function)
|
// We have an edge case if ActiveId was set through another widget (e.g. widget being swapped), clear id immediately (don't wait until the end of the function)
|
||||||
@ -4316,8 +4316,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
|
|
||||||
// We expect backends to emit a Tab key but some also emit a Tab character which we ignore (#2467, #1336)
|
// We expect backends to emit a Tab key but some also emit a Tab character which we ignore (#2467, #1336)
|
||||||
// (For Tab and Enter: Win32/SFML/Allegro are sending both keys and chars, GLFW and SDL are only sending keys. For Space they all send all threes)
|
// (For Tab and Enter: Win32/SFML/Allegro are sending both keys and chars, GLFW and SDL are only sending keys. For Space they all send all threes)
|
||||||
const bool ignore_char_inputs = (io.KeyCtrl && !io.KeyAlt) || (is_osx && io.KeySuper);
|
if ((flags & ImGuiInputTextFlags_AllowTabInput) && Shortcut(ImGuiKey_Tab, id) && !is_readonly)
|
||||||
if ((flags & ImGuiInputTextFlags_AllowTabInput) && IsKeyPressed(ImGuiKey_Tab) && !ignore_char_inputs && !io.KeyShift && !is_readonly)
|
|
||||||
{
|
{
|
||||||
unsigned int c = '\t'; // Insert TAB
|
unsigned int c = '\t'; // Insert TAB
|
||||||
if (InputTextFilterCharacter(&c, flags, callback, callback_user_data, ImGuiInputSource_Keyboard))
|
if (InputTextFilterCharacter(&c, flags, callback, callback_user_data, ImGuiInputSource_Keyboard))
|
||||||
@ -4326,6 +4325,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
|
|
||||||
// Process regular text input (before we check for Return because using some IME will effectively send a Return?)
|
// Process regular text input (before we check for Return because using some IME will effectively send a Return?)
|
||||||
// We ignore CTRL inputs, but need to allow ALT+CTRL as some keyboards (e.g. German) use AltGR (which _is_ Alt+Ctrl) to input certain characters.
|
// We ignore CTRL inputs, but need to allow ALT+CTRL as some keyboards (e.g. German) use AltGR (which _is_ Alt+Ctrl) to input certain characters.
|
||||||
|
const bool ignore_char_inputs = (io.KeyCtrl && !io.KeyAlt) || (is_osx && io.KeySuper);
|
||||||
if (io.InputQueueCharacters.Size > 0)
|
if (io.InputQueueCharacters.Size > 0)
|
||||||
{
|
{
|
||||||
if (!ignore_char_inputs && !is_readonly && !input_requested_by_nav)
|
if (!ignore_char_inputs && !is_readonly && !input_requested_by_nav)
|
||||||
@ -4562,7 +4562,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
// The reason we specify the usage semantic (Completion/History) is that Completion needs to disable keyboard TABBING at the moment.
|
// The reason we specify the usage semantic (Completion/History) is that Completion needs to disable keyboard TABBING at the moment.
|
||||||
ImGuiInputTextFlags event_flag = 0;
|
ImGuiInputTextFlags event_flag = 0;
|
||||||
ImGuiKey event_key = ImGuiKey_None;
|
ImGuiKey event_key = ImGuiKey_None;
|
||||||
if ((flags & ImGuiInputTextFlags_CallbackCompletion) != 0 && IsKeyPressed(ImGuiKey_Tab))
|
if ((flags & ImGuiInputTextFlags_CallbackCompletion) != 0 && Shortcut(ImGuiKey_Tab, id))
|
||||||
{
|
{
|
||||||
event_flag = ImGuiInputTextFlags_CallbackCompletion;
|
event_flag = ImGuiInputTextFlags_CallbackCompletion;
|
||||||
event_key = ImGuiKey_Tab;
|
event_key = ImGuiKey_Tab;
|
||||||
|
Loading…
Reference in New Issue
Block a user