From 3c3cde99bed5f589c7522243b029e9f79baa949d Mon Sep 17 00:00:00 2001 From: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> Date: Wed, 13 Oct 2021 13:33:59 -0700 Subject: [PATCH] LYN-7189 | Outliner - Disable context menu if right clicking on disabled entity (#4651) * Don't allow right clicking on a non selectable entity in the Outliner Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Also check that the index is valid to still allow the right click context menu to appear on empty areas of the widget. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Change if check to a more readable bool. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> --- .../AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp index 3b48cc4967..4d53102edb 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp @@ -553,6 +553,13 @@ namespace AzToolsFramework return; } + // Do not display the context menu if the item under the mouse cursor is not selectable. + if (const QModelIndex& index = m_gui->m_objectTree->indexAt(pos); index.isValid() + && (index.flags() & Qt::ItemIsSelectable) == 0) + { + return; + } + QMenu* contextMenu = new QMenu(this); // Populate global context menu.