diff --git a/lcl/interfaces/qt/qtwidgets.pas b/lcl/interfaces/qt/qtwidgets.pas index b72ece691d..e1ff46c574 100644 --- a/lcl/interfaces/qt/qtwidgets.pas +++ b/lcl/interfaces/qt/qtwidgets.pas @@ -1557,6 +1557,7 @@ type function getHasSubMenu: boolean; function getText: WideString; override; function getVisible: Boolean; override; + function MenuItemEnabled: boolean; procedure PopUp(pos: PQtPoint; at: QActionH = nil); procedure Exec(pos: PQtPoint; at: QActionH = nil); procedure removeActionGroup; @@ -14931,6 +14932,27 @@ begin end; end; +function TQtMenu.MenuItemEnabled: boolean; +var + AParentMenu: TMenuItem; +begin + if not Assigned(FMenuItem) then + begin + Result := getEnabled; + exit; + end; + + Result := FMenuItem.Enabled; + AParentMenu := FMenuItem.Parent; + while AParentMenu <> nil do + begin + Result := AParentMenu.Enabled; + if not Result then + break; + AParentMenu := AParentMenu.Parent; + end; +end; + function TQtMenu.EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; var Msg: TLMessage; @@ -14944,7 +14966,7 @@ begin begin FillChar(Msg, SizeOf(Msg), 0); Msg.msg := LM_ACTIVATE; - if Assigned(FMenuItem) then + if MenuItemEnabled then FMenuItem.Dispatch(Msg); Result := True; end;