@ -10060,15 +10060,15 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
const float mouse_x = ( io . MousePos . x - frame_bb . Min . x - style . FramePadding . x ) + edit_state . ScrollX ;
const float mouse_y = ( is_multiline ? ( io . MousePos . y - draw_window - > DC . CursorPos . y - style . FramePadding . y ) : ( g . FontSize * 0.5f ) ) ;
const bool osx_double_cl ick_select s_w ord s = io . OptMacOSXBehaviors ; // OS X style: Double click selects by word instead of selecting whole text
if ( select_all | | ( hovered & & ! osx_double_cl ick_select s_w ord s & & io . MouseDoubleClicked [ 0 ] ) )
const bool is_osx = io . OptMacOSXBehaviors ;
if ( select_all | | ( hovered & & ! is_osx & & io . MouseDoubleClicked [ 0 ] ) )
{
edit_state . SelectAll ( ) ;
edit_state . SelectedAllMouseLock = true ;
}
else if ( hovered & & osx_double_cl ick_select s_w ord s & & io . MouseDoubleClicked [ 0 ] )
else if ( hovered & & is_osx & & io . MouseDoubleClicked [ 0 ] )
{
// S elect a word only, OS X style (by simulating keystrokes)
// Double-click s elect a word only, OS X style (by simulating keystrokes)
edit_state . OnKeyPressed ( STB_TEXTEDIT_K_WORDLEFT ) ;
edit_state . OnKeyPressed ( STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT ) ;
}
@ -10093,7 +10093,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
{
// Process 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.
bool ignore_inputs = ( io . KeyCtrl & & ! io . KeyAlt ) | | ( i o. OptMacOSXBehavior s & & io . KeySuper ) ;
bool ignore_inputs = ( io . KeyCtrl & & ! io . KeyAlt ) | | ( i s_ osx & & io . KeySuper ) ;
if ( ! ignore_inputs & & is_editable & & ! user_nav_input_start )
for ( int n = 0 ; n < IM_ARRAYSIZE ( io . InputCharacters ) & & io . InputCharacters [ n ] ; n + + )
{
@ -10113,15 +10113,18 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
{
// Handle key-presses
const int k_mask = ( io . KeyShift ? STB_TEXTEDIT_K_SHIFT : 0 ) ;
const bool is_shortcut_key_only = ( io . OptMacOSXBehaviors ? ( io . KeySuper & & ! io . KeyCtrl ) : ( io . KeyCtrl & & ! io . KeySuper ) ) & & ! io . KeyAlt & & ! io . KeyShift ; // OS X style: Shortcuts using Cmd/Super instead of Ctrl
const bool is_wordmove_key_down = io . OptMacOSXBehaviors ? io . KeyAlt : io . KeyCtrl ; // OS X style: Text editing cursor movement using Alt instead of Ctrl
const bool is_startend_key_down = io . OptMacOSXBehaviors & & io . KeySuper & & ! io . KeyCtrl & & ! io . KeyAlt ; // OS X style: Line/Text Start and End using Cmd+Arrows instead of Home/End
const bool is_osx = io . OptMacOSXBehaviors ;
const bool is_shortcut_key = ( is_osx ? ( io . KeySuper & & ! io . KeyCtrl ) : ( io . KeyCtrl & & ! io . KeySuper ) ) & & ! io . KeyAlt & & ! io . KeyShift ; // OS X style: Shortcuts using Cmd/Super instead of Ctrl
const bool is_wordmove_key_down = is_osx ? io . KeyAlt : io . KeyCtrl ; // OS X style: Text editing cursor movement using Alt instead of Ctrl
const bool is_startend_key_down = is_osx & & io . KeySuper & & ! io . KeyCtrl & & ! io . KeyAlt ; // OS X style: Line/Text Start and End using Cmd+Arrows instead of Home/End
const bool is_ctrl_key_only = io . KeyCtrl & & ! io . KeyShift & & ! io . KeyAlt & & ! io . KeySuper ;
const bool is_shift_key_only = io . KeyShift & & ! io . KeyCtrl & & ! io . KeyAlt & & ! io . KeySuper ;
const bool is_cut = ( ( is_shortcut_key_only & & IsKeyPressedMap ( ImGuiKey_X ) ) | | ( is_shift_key_only & & IsKeyPressedMap ( ImGuiKey_Delete ) ) ) & & is_editable & & ! is_password & & ( ! is_multiline | | edit_state . HasSelection ( ) ) ;
const bool is_copy = ( ( is_shortcut_key_only & & IsKeyPressedMap ( ImGuiKey_C ) ) | | ( is_ctrl_key_only & & IsKeyPressedMap ( ImGuiKey_Insert ) ) ) & & ! is_password & & ( ! is_multiline | | edit_state . HasSelection ( ) ) ;
const bool is_paste = ( ( is_shortcut_key_only & & IsKeyPressedMap ( ImGuiKey_V ) ) | | ( is_shift_key_only & & IsKeyPressedMap ( ImGuiKey_Insert ) ) ) & & is_editable ;
const bool is_cut = ( ( is_shortcut_key & & IsKeyPressedMap ( ImGuiKey_X ) ) | | ( is_shift_key_only & & IsKeyPressedMap ( ImGuiKey_Delete ) ) ) & & is_editable & & ! is_password & & ( ! is_multiline | | edit_state . HasSelection ( ) ) ;
const bool is_copy = ( ( is_shortcut_key & & IsKeyPressedMap ( ImGuiKey_C ) ) | | ( is_ctrl_key_only & & IsKeyPressedMap ( ImGuiKey_Insert ) ) ) & & ! is_password & & ( ! is_multiline | | edit_state . HasSelection ( ) ) ;
const bool is_paste = ( ( is_shortcut_key & & IsKeyPressedMap ( ImGuiKey_V ) ) | | ( is_shift_key_only & & IsKeyPressedMap ( ImGuiKey_Insert ) ) ) & & is_editable ;
const bool is_undo = ( is_shortcut_key & & IsKeyPressedMap ( ImGuiKey_Z ) & & is_editable & & is_undoable ) ;
const bool is_redo = ( is_shortcut_key & & IsKeyPressedMap ( ImGuiKey_Y ) & & is_editable & & is_undoable ) ;
if ( IsKeyPressedMap ( ImGuiKey_LeftArrow ) ) { edit_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 ) ) { edit_state . OnKeyPressed ( ( is_startend_key_down ? STB_TEXTEDIT_K_LINEEND : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDRIGHT : STB_TEXTEDIT_K_RIGHT ) | k_mask ) ; }
@ -10135,7 +10138,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
if ( ! edit_state . HasSelection ( ) )
{
if ( is_wordmove_key_down ) edit_state . OnKeyPressed ( STB_TEXTEDIT_K_WORDLEFT | STB_TEXTEDIT_K_SHIFT ) ;
else if ( i o. OptMacOSXBehavior s & & io . KeySuper & & ! io . KeyAlt & & ! io . KeyCtrl ) edit_state . OnKeyPressed ( STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT ) ;
else if ( i s_ osx & & io . KeySuper & & ! io . KeyAlt & & ! io . KeyCtrl ) edit_state . OnKeyPressed ( STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT ) ;
}
edit_state . OnKeyPressed ( STB_TEXTEDIT_K_BACKSPACE | k_mask ) ;
}
@ -10159,10 +10162,20 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
if ( InputTextFilterCharacter ( & c , flags , callback , user_data ) )
edit_state . OnKeyPressed ( ( int ) c ) ;
}
else if ( IsKeyPressedMap ( ImGuiKey_Escape ) ) { clear_active_id = cancel_edit = true ; }
else if ( is_shortcut_key_only & & IsKeyPressedMap ( ImGuiKey_Z ) & & is_editable & & is_undoable ) { edit_state . OnKeyPressed ( STB_TEXTEDIT_K_UNDO ) ; edit_state . ClearSelection ( ) ; }
else if ( is_shortcut_key_only & & IsKeyPressedMap ( ImGuiKey_Y ) & & is_editable & & is_undoable ) { edit_state . OnKeyPressed ( STB_TEXTEDIT_K_REDO ) ; edit_state . ClearSelection ( ) ; }
else if ( is_shortcut_key_only & & IsKeyPressedMap ( ImGuiKey_A ) ) { edit_state . SelectAll ( ) ; edit_state . CursorFollow = true ; }
else if ( IsKeyPressedMap ( ImGuiKey_Escape ) )
{
clear_active_id = cancel_edit = true ;
}
else if ( is_undo | | is_redo )
{
edit_state . OnKeyPressed ( is_undo ? STB_TEXTEDIT_K_UNDO : STB_TEXTEDIT_K_REDO ) ;
edit_state . ClearSelection ( ) ;
}
else if ( is_shortcut_key & & IsKeyPressedMap ( ImGuiKey_A ) )
{
edit_state . SelectAll ( ) ;
edit_state . CursorFollow = true ;
}
else if ( is_cut | | is_copy )
{
// Cut, Copy
@ -10174,7 +10187,6 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
ImTextStrToUtf8 ( edit_state . TempTextBuffer . Data , edit_state . TempTextBuffer . Size , edit_state . Text . Data + ib , edit_state . Text . Data + ie ) ;
SetClipboardText ( edit_state . TempTextBuffer . Data ) ;
}
if ( is_cut )
{
if ( ! edit_state . HasSelection ( ) )
@ -10185,7 +10197,6 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
}
else if ( is_paste )
{
// Paste
if ( const char * clipboard = GetClipboardText ( ) )
{
// Filter pasted buffer