@ -1874,6 +1874,7 @@ bool ImGui::Combo(const char* label, int* current_item, const char* items_separa
// - DataTypeFormatString()
// - DataTypeFormatString()
// - DataTypeApplyOp()
// - DataTypeApplyOp()
// - DataTypeApplyOpFromText()
// - DataTypeApplyOpFromText()
// - DataTypeCompare()
// - DataTypeClamp()
// - DataTypeClamp()
// - GetMinimumStepAtDecimalPrecision
// - GetMinimumStepAtDecimalPrecision
// - RoundScalarWithFormat<>()
// - RoundScalarWithFormat<>()
@ -2279,6 +2280,7 @@ bool ImGui::DragBehavior(ImGuiID id, ImGuiDataType data_type, void* p_v, float v
ImGuiContext & g = * GImGui ;
ImGuiContext & g = * GImGui ;
if ( g . ActiveId = = id )
if ( g . ActiveId = = id )
{
{
// Those are the things we can do easily outside the DragBehaviorT<> template, saves code generation.
if ( g . ActiveIdSource = = ImGuiInputSource_Mouse & & ! g . IO . MouseDown [ 0 ] )
if ( g . ActiveIdSource = = ImGuiInputSource_Mouse & & ! g . IO . MouseDown [ 0 ] )
ClearActiveID ( ) ;
ClearActiveID ( ) ;
else if ( g . ActiveIdSource = = ImGuiInputSource_Nav & & g . NavActivatePressedId = = id & & ! g . ActiveIdIsJustActivated )
else if ( g . ActiveIdSource = = ImGuiInputSource_Nav & & g . NavActivatePressedId = = id & & ! g . ActiveIdIsJustActivated )
@ -2893,6 +2895,7 @@ bool ImGui::SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type
// Read imgui.cpp "API BREAKING CHANGES" section for 1.78 if you hit this assert.
// Read imgui.cpp "API BREAKING CHANGES" section for 1.78 if you hit this assert.
IM_ASSERT ( ( flags = = 1 | | ( flags & ImGuiSliderFlags_InvalidMask_ ) = = 0 ) & & " Invalid ImGuiSliderFlags flag! Has the 'float power' argument been mistakenly cast to flags? Call function with ImGuiSliderFlags_Logarithmic flags instead. " ) ;
IM_ASSERT ( ( flags = = 1 | | ( flags & ImGuiSliderFlags_InvalidMask_ ) = = 0 ) & & " Invalid ImGuiSliderFlags flag! Has the 'float power' argument been mistakenly cast to flags? Call function with ImGuiSliderFlags_Logarithmic flags instead. " ) ;
// Those are the things we can do easily outside the SliderBehaviorT<> template, saves code generation.
ImGuiContext & g = * GImGui ;
ImGuiContext & g = * GImGui ;
if ( ( g . LastItemData . InFlags & ImGuiItemFlags_ReadOnly ) | | ( flags & ImGuiSliderFlags_ReadOnly ) )
if ( ( g . LastItemData . InFlags & ImGuiItemFlags_ReadOnly ) | | ( flags & ImGuiSliderFlags_ReadOnly ) )
return false ;
return false ;
@ -3686,13 +3689,10 @@ static int is_word_boundary_from_right(ImGuiInputTextState* obj, int idx)
static int is_word_boundary_from_left ( ImGuiInputTextState * obj , int idx ) { if ( obj - > Flags & ImGuiInputTextFlags_Password ) return 0 ; return idx > 0 ? ( ! is_separator ( obj - > TextW [ idx - 1 ] ) & & is_separator ( obj - > TextW [ idx ] ) ) : 1 ; }
static int is_word_boundary_from_left ( ImGuiInputTextState * obj , int idx ) { if ( obj - > Flags & ImGuiInputTextFlags_Password ) return 0 ; return idx > 0 ? ( ! is_separator ( obj - > TextW [ idx - 1 ] ) & & is_separator ( obj - > TextW [ idx ] ) ) : 1 ; }
static int STB_TEXTEDIT_MOVEWORDLEFT_IMPL ( ImGuiInputTextState * obj , int idx ) { idx - - ; while ( idx > = 0 & & ! is_word_boundary_from_right ( obj , idx ) ) idx - - ; return idx < 0 ? 0 : idx ; }
static int STB_TEXTEDIT_MOVEWORDLEFT_IMPL ( ImGuiInputTextState * obj , int idx ) { idx - - ; while ( idx > = 0 & & ! is_word_boundary_from_right ( obj , idx ) ) idx - - ; return idx < 0 ? 0 : idx ; }
static int STB_TEXTEDIT_MOVEWORDRIGHT_MAC ( ImGuiInputTextState * obj , int idx ) { idx + + ; int len = obj - > CurLenW ; while ( idx < len & & ! is_word_boundary_from_left ( obj , idx ) ) idx + + ; return idx > len ? len : idx ; }
static int STB_TEXTEDIT_MOVEWORDRIGHT_MAC ( ImGuiInputTextState * obj , int idx ) { idx + + ; int len = obj - > CurLenW ; while ( idx < len & & ! is_word_boundary_from_left ( obj , idx ) ) idx + + ; return idx > len ? len : idx ; }
# define STB_TEXTEDIT_MOVEWORDLEFT STB_TEXTEDIT_MOVEWORDLEFT_IMPL // They need to be #define for stb_textedit.h
# ifdef __APPLE__ // FIXME: Move setting to IO structure
# define STB_TEXTEDIT_MOVEWORDRIGHT STB_TEXTEDIT_MOVEWORDRIGHT_MAC
# else
static int STB_TEXTEDIT_MOVEWORDRIGHT_WIN ( ImGuiInputTextState * obj , int idx ) { idx + + ; int len = obj - > CurLenW ; while ( idx < len & & ! is_word_boundary_from_right ( obj , idx ) ) idx + + ; return idx > len ? len : idx ; }
static int STB_TEXTEDIT_MOVEWORDRIGHT_WIN ( ImGuiInputTextState * obj , int idx ) { idx + + ; int len = obj - > CurLenW ; while ( idx < len & & ! is_word_boundary_from_right ( obj , idx ) ) idx + + ; return idx > len ? len : idx ; }
# define STB_TEXTEDIT_MOVEWORDRIGHT STB_TEXTEDIT_MOVEWORDRIGHT_WIN
static int STB_TEXTEDIT_MOVEWORDRIGHT_IMPL ( ImGuiInputTextState * obj , int idx ) { if ( ImGui : : GetIO ( ) . ConfigMacOSXBehaviors ) return STB_TEXTEDIT_MOVEWORDRIGHT_MAC ( obj , idx ) ; else return STB_TEXTEDIT_MOVEWORDRIGHT_WIN ( obj , idx ) ; }
# endif
# define STB_TEXTEDIT_MOVEWORDLEFT STB_TEXTEDIT_MOVEWORDLEFT_IMPL // They need to be #define for stb_textedit.h
# define STB_TEXTEDIT_MOVEWORDRIGHT STB_TEXTEDIT_MOVEWORDRIGHT_IMPL
static void STB_TEXTEDIT_DELETECHARS ( ImGuiInputTextState * obj , int pos , int n )
static void STB_TEXTEDIT_DELETECHARS ( ImGuiInputTextState * obj , int pos , int n )
{
{
@ -4283,7 +4283,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
if ( state - > SelectedAllMouseLock & & ! io . MouseDown [ 0 ] )
if ( state - > SelectedAllMouseLock & & ! io . MouseDown [ 0 ] )
state - > SelectedAllMouseLock = false ;
state - > SelectedAllMouseLock = false ;
// We exce pt backends to emit a Tab key but some also emit a Tab character which we ignore (#2467, #1336)
// We expec t 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 ) ;
const bool ignore_char_inputs = ( io . KeyCtrl & & ! io . KeyAlt ) | | ( is_osx & & io . KeySuper ) ;
if ( ( flags & ImGuiInputTextFlags_AllowTabInput ) & & IsKeyPressed ( ImGuiKey_Tab ) & & ! ignore_char_inputs & & ! io . KeyShift & & ! is_readonly )
if ( ( flags & ImGuiInputTextFlags_AllowTabInput ) & & IsKeyPressed ( ImGuiKey_Tab ) & & ! ignore_char_inputs & & ! io . KeyShift & & ! is_readonly )
@ -4336,6 +4336,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
const bool is_paste = ( ( is_shortcut_key & & IsKeyPressed ( ImGuiKey_V ) ) | | ( is_shift_key_only & & IsKeyPressed ( ImGuiKey_Insert ) ) ) & & ! is_readonly ;
const bool is_paste = ( ( is_shortcut_key & & IsKeyPressed ( ImGuiKey_V ) ) | | ( is_shift_key_only & & IsKeyPressed ( ImGuiKey_Insert ) ) ) & & ! is_readonly ;
const bool is_undo = ( ( is_shortcut_key & & IsKeyPressed ( ImGuiKey_Z ) ) & & ! is_readonly & & is_undoable ) ;
const bool is_undo = ( ( is_shortcut_key & & IsKeyPressed ( ImGuiKey_Z ) ) & & ! is_readonly & & is_undoable ) ;
const bool is_redo = ( ( is_shortcut_key & & IsKeyPressed ( ImGuiKey_Y ) ) | | ( is_osx_shift_shortcut & & IsKeyPressed ( ImGuiKey_Z ) ) ) & & ! is_readonly & & is_undoable ;
const bool is_redo = ( ( is_shortcut_key & & IsKeyPressed ( ImGuiKey_Y ) ) | | ( is_osx_shift_shortcut & & IsKeyPressed ( ImGuiKey_Z ) ) ) & & ! is_readonly & & is_undoable ;
const bool is_select_all = is_shortcut_key & & IsKeyPressed ( ImGuiKey_A ) ;
// 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.
// 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_enter_pressed = IsKeyPressed ( ImGuiKey_Enter ) | | IsKeyPressed ( ImGuiKey_KeypadEnter ) ;
const bool is_enter_pressed = IsKeyPressed ( ImGuiKey_Enter ) | | IsKeyPressed ( ImGuiKey_KeypadEnter ) ;
@ -4395,7 +4396,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
state - > OnKeyPressed ( is_undo ? STB_TEXTEDIT_K_UNDO : STB_TEXTEDIT_K_REDO ) ;
state - > OnKeyPressed ( is_undo ? STB_TEXTEDIT_K_UNDO : STB_TEXTEDIT_K_REDO ) ;
state - > ClearSelection ( ) ;
state - > ClearSelection ( ) ;
}
}
else if ( is_shortcut_key & & IsKeyPressed ( ImGuiKey_A ) )
else if ( is_select_all )
{
{
state - > SelectAll ( ) ;
state - > SelectAll ( ) ;
state - > CursorFollow = true ;
state - > CursorFollow = true ;