@ -571,6 +571,8 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
ClearActiveID ( ) ;
ClearActiveID ( ) ;
else
else
SetActiveID ( id , window ) ; // Hold on ID
SetActiveID ( id , window ) ; // Hold on ID
if ( ! ( flags & ImGuiButtonFlags_NoNavFocus ) )
SetFocusID ( id , window ) ;
g . ActiveIdMouseButton = mouse_button_clicked ;
g . ActiveIdMouseButton = mouse_button_clicked ;
FocusWindow ( window ) ;
FocusWindow ( window ) ;
}
}
@ -581,6 +583,8 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
const bool has_repeated_at_least_once = ( flags & ImGuiButtonFlags_Repeat ) & & g . IO . MouseDownDurationPrev [ mouse_button_released ] > = g . IO . KeyRepeatDelay ;
const bool has_repeated_at_least_once = ( flags & ImGuiButtonFlags_Repeat ) & & g . IO . MouseDownDurationPrev [ mouse_button_released ] > = g . IO . KeyRepeatDelay ;
if ( ! has_repeated_at_least_once )
if ( ! has_repeated_at_least_once )
pressed = true ;
pressed = true ;
if ( ! ( flags & ImGuiButtonFlags_NoNavFocus ) )
SetFocusID ( id , window ) ;
ClearActiveID ( ) ;
ClearActiveID ( ) ;
}
}
@ -6860,7 +6864,7 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
}
}
else
else
{
{
// Menu inside a menu
// Menu inside a regular/vertical menu
// (In a typical menu window where all items are BeginMenu() or MenuItem() calls, extra_w will always be 0.0f.
// (In a typical menu window where all items are BeginMenu() or MenuItem() calls, extra_w will always be 0.0f.
// Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system.
// Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system.
popup_pos = ImVec2 ( pos . x , pos . y - style . WindowPadding . y ) ;
popup_pos = ImVec2 ( pos . x , pos . y - style . WindowPadding . y ) ;
@ -6981,11 +6985,12 @@ void ImGui::EndMenu()
// However, it means that with the current code, a BeginMenu() from outside another menu or a menu-bar won't be closable with the Left direction.
// However, it means that with the current code, a BeginMenu() from outside another menu or a menu-bar won't be closable with the Left direction.
ImGuiContext & g = * GImGui ;
ImGuiContext & g = * GImGui ;
ImGuiWindow * window = g . CurrentWindow ;
ImGuiWindow * window = g . CurrentWindow ;
if ( g . NavWindow & & g . NavWindow - > ParentWindow = = window & & g . NavMoveDir = = ImGuiDir_Left & & NavMoveRequestButNoResultYet ( ) & & window - > DC . LayoutType = = ImGuiLayoutType_Vertical )
if ( g . NavMoveDir = = ImGuiDir_Left & & NavMoveRequestButNoResultYet ( ) & & window - > DC . LayoutType = = ImGuiLayoutType_Vertical )
{
if ( g . NavWindow & & ( g . NavWindow - > RootWindowForNav - > Flags & ImGuiWindowFlags_Popup ) & & g . NavWindow - > RootWindowForNav - > ParentWindow = = window )
ClosePopupToLevel ( g . BeginPopupStack . Size , true ) ;
{
NavMoveRequestCancel ( ) ;
ClosePopupToLevel ( g . BeginPopupStack . Size , true ) ;
}
NavMoveRequestCancel ( ) ;
}
EndPopup ( ) ;
EndPopup ( ) ;
}
}
@ -7015,10 +7020,11 @@ bool ImGui::MenuItemEx(const char* label, const char* icon, const char* shortcut
// Note that in this situation: we don't render the shortcut, we render a highlight instead of the selected tick mark.
// Note that in this situation: we don't render the shortcut, we render a highlight instead of the selected tick mark.
float w = label_size . x ;
float w = label_size . x ;
window - > DC . CursorPos . x + = IM_FLOOR ( style . ItemSpacing . x * 0.5f ) ;
window - > DC . CursorPos . x + = IM_FLOOR ( style . ItemSpacing . x * 0.5f ) ;
ImVec2 text_pos ( window - > DC . CursorPos . x + offsets - > OffsetLabel , window - > DC . CursorPos . y + window - > DC . CurrLineTextBaseOffset ) ;
PushStyleVar ( ImGuiStyleVar_ItemSpacing , ImVec2 ( style . ItemSpacing . x * 2.0f , style . ItemSpacing . y ) ) ;
PushStyleVar ( ImGuiStyleVar_ItemSpacing , ImVec2 ( style . ItemSpacing . x * 2.0f , style . ItemSpacing . y ) ) ;
pressed = Selectable ( " " , selected , flags , ImVec2 ( w , 0.0f ) ) ;
pressed = Selectable ( " " , selected , flags , ImVec2 ( w , 0.0f ) ) ;
PopStyleVar ( ) ;
PopStyleVar ( ) ;
RenderText ( pos + ImVec2 ( offsets - > OffsetLabel , 0.0f ) , label ) ;
RenderText ( text_pos , label ) ;
window - > DC . CursorPos . x + = IM_FLOOR ( style . ItemSpacing . x * ( - 1.0f + 0.5f ) ) ; // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar().
window - > DC . CursorPos . x + = IM_FLOOR ( style . ItemSpacing . x * ( - 1.0f + 0.5f ) ) ; // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar().
}
}
else
else