mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 03:10:30 +02:00
Qt: do not trigger shortcuts if menu item is disabled. issue #21720
git-svn-id: trunk@46113 -
This commit is contained in:
parent
0aef03aadb
commit
988960ce47
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user