@ -4246,6 +4246,10 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
const bool is_undo = ( ( is_shortcut_key & & IsKeyPressedMap ( ImGuiKey_Z ) ) & & ! is_readonly & & is_undoable ) ;
const bool is_redo = ( ( is_shortcut_key & & IsKeyPressedMap ( ImGuiKey_Y ) ) | | ( is_osx_shift_shortcut & & IsKeyPressedMap ( ImGuiKey_Z ) ) ) & & ! is_readonly & & is_undoable ;
// We allow validate/cancel with Nav source (gamepad) to makes it easier to undo an accidental NavInput press with no keyboard wired, but otherwise it isn't very useful.
const bool is_validate = IsKeyPressedMap ( ImGuiKey_Enter ) | | IsKeyPressedMap ( ImGuiKey_KeyPadEnter ) | | IsNavInputTest ( ImGuiNavInput_Activate , ImGuiInputReadMode_Pressed ) | | IsNavInputTest ( ImGuiNavInput_Input , ImGuiInputReadMode_Pressed ) ;
const bool is_cancel = IsKeyPressedMap ( ImGuiKey_Escape ) | | IsNavInputTest ( ImGuiNavInput_Cancel , ImGuiInputReadMode_Pressed ) ;
if ( IsKeyPressedMap ( ImGuiKey_LeftArrow ) ) { state - > OnKeyPressed ( ( is_startend_key_down ? STB_TEXTEDIT_K_LINESTART : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDLEFT : STB_TEXTEDIT_K_LEFT ) | k_mask ) ; }
else if ( IsKeyPressedMap ( ImGuiKey_RightArrow ) ) { state - > OnKeyPressed ( ( is_startend_key_down ? STB_TEXTEDIT_K_LINEEND : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDRIGHT : STB_TEXTEDIT_K_RIGHT ) | k_mask ) ; }
else if ( IsKeyPressedMap ( ImGuiKey_UpArrow ) & & is_multiline ) { if ( io . KeyCtrl ) SetScrollY ( draw_window , ImMax ( draw_window - > Scroll . y - g . FontSize , 0.0f ) ) ; else state - > OnKeyPressed ( ( is_startend_key_down ? STB_TEXTEDIT_K_TEXTSTART : STB_TEXTEDIT_K_UP ) | k_mask ) ; }
@ -4266,7 +4270,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
}
state - > OnKeyPressed ( STB_TEXTEDIT_K_BACKSPACE | k_mask ) ;
}
else if ( IsKeyPressedMap( ImGuiKey_Enter ) | | IsKeyPressedMap ( ImGuiKey_KeyPadEnter ) )
else if ( is_validate )
{
bool ctrl_enter_for_new_line = ( flags & ImGuiInputTextFlags_CtrlEnterForNewLine ) ! = 0 ;
if ( ! is_multiline | | ( ctrl_enter_for_new_line & & ! io . KeyCtrl ) | | ( ! ctrl_enter_for_new_line & & io . KeyCtrl ) )
@ -4280,7 +4284,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
state - > OnKeyPressed ( ( int ) c ) ;
}
}
else if ( IsKeyPressedMap( ImGuiKey_Escape ) )
else if ( is_cancel )
{
clear_active_id = cancel_edit = true ;
}