@ -6356,19 +6356,11 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
// Multi-selection support (header)
if ( is_multi_select )
{
MultiSelectItemHeader ( id , & selected ) ;
button_flags | = ImGuiButtonFlags_NoHoveredOnFocus ;
// Handle multi-select + alter button flags for it
MultiSelectItemHeader ( id , & selected , & button_flags ) ;
// We absolutely need to distinguish open vs select so this is the default when multi-select is enabled.
// We absolutely need to distinguish open vs select so comes by default
flags | = ImGuiTreeNodeFlags_OpenOnArrow ;
// To handle drag and drop of multiple items we need to avoid clearing selection on click.
// Enabling this test makes actions using CTRL+SHIFT delay their effect on MouseUp which is annoying, but it allows drag and drop of multiple items.
// FIXME-MULTISELECT: Consider opt-in for drag and drop behavior in ImGuiMultiSelectFlags?
if ( ! selected | | ( g . ActiveId = = id & & g . ActiveIdHasBeenPressedBefore ) )
button_flags = ( button_flags | ImGuiButtonFlags_PressedOnClick ) & ~ ImGuiButtonFlags_PressedOnClickRelease ;
else
button_flags | = ImGuiButtonFlags_PressedOnClickRelease ;
}
else
{
@ -6705,15 +6697,8 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
const bool was_selected = selected ;
if ( is_multi_select )
{
MultiSelectItemHeader ( id , & selected ) ;
button_flags | = ImGuiButtonFlags_NoHoveredOnFocus ;
// To handle drag and drop of multiple items we need to avoid clearing selection on click.
// Enabling this test makes actions using CTRL+SHIFT delay their effect on the mouse release which is annoying, but it allows drag and drop of multiple items.
if ( ! selected | | ( g . ActiveId = = id & & g . ActiveIdHasBeenPressedBefore ) )
button_flags | = ImGuiButtonFlags_PressedOnClick ;
else
button_flags | = ImGuiButtonFlags_PressedOnClickRelease ;
// Handle multi-select + alter button flags for it
MultiSelectItemHeader ( id , & selected , & button_flags ) ;
}
bool hovered , held ;
@ -7154,21 +7139,21 @@ void ImGui::SetNextItemSelectionUserData(ImGuiSelectionUserData selection_user_d
}
}
void ImGui : : MultiSelectItemHeader ( ImGuiID id , bool * p_selected )
void ImGui : : MultiSelectItemHeader ( ImGuiID id , bool * p_selected , ImGuiButtonFlags * p_button_flags )
{
ImGuiContext & g = * GImGui ;
ImGuiMultiSelectTempData * ms = g . CurrentMultiSelect ;
if ( ! ms - > IsFocused )
return ;
ImGuiMultiSelectState * storage = ms - > Storage ;
IM_ASSERT ( g . NextItemData . FocusScopeId = = g . CurrentFocusScopeId & & " Forgot to call SetNextItemSelectionUserData() prior to item, required in BeginMultiSelect()/EndMultiSelect() scope " ) ;
bool selected = * p_selected ;
if ( ms - > IsFocused )
{
ImGuiMultiSelectState * storage = ms - > Storage ;
ImGuiSelectionUserData item_data = g . NextItemData . SelectionUserData ;
IM_ASSERT ( g . NextItemData . FocusScopeId = = g . CurrentFocusScopeId & & " Forgot to call SetNextItemSelectionUserData() prior to item, required in BeginMultiSelect()/EndMultiSelect() scope " ) ;
// Apply Clear/SelectAll requests requested by BeginMultiSelect().
// This is only useful if the user hasn't processed them already, and this only works if the user isn't using the clipper.
// If you are using a clipper (aka not submitting every element of the list) you need to process the Clear/SelectAll request after calling BeginMultiSelect()
bool selected = * p_selected ;
if ( ms - > BeginIO . RequestClear )
selected = false ;
else if ( ms - > BeginIO . RequestSelectAll )
@ -7198,10 +7183,22 @@ void ImGui::MultiSelectItemHeader(ImGuiID id, bool* p_selected)
else if ( ( ms - > KeyMods & ImGuiMod_Ctrl ) = = 0 )
selected = false ;
}
* p_selected = selected ;
}
// Alter button behavior flags
// To handle drag and drop of multiple items we need to avoid clearing selection on click.
// Enabling this test makes actions using CTRL+SHIFT delay their effect on MouseUp which is annoying, but it allows drag and drop of multiple items.
// FIXME-MULTISELECT: Consider opt-in for drag and drop behavior in ImGuiMultiSelectFlags?
ImGuiButtonFlags button_flags = * p_button_flags ;
button_flags | = ImGuiButtonFlags_NoHoveredOnFocus ;
if ( ! selected | | ( g . ActiveId = = id & & g . ActiveIdHasBeenPressedBefore ) )
button_flags = ( button_flags | ImGuiButtonFlags_PressedOnClick ) & ~ ImGuiButtonFlags_PressedOnClickRelease ;
else
button_flags | = ImGuiButtonFlags_PressedOnClickRelease ;
* p_button_flags = button_flags ;
}
void ImGui : : MultiSelectItemFooter ( ImGuiID id , bool * p_selected , bool * p_pressed )
{
ImGuiContext & g = * GImGui ;