From 9a9d68c78d31e18ca0c529b99697195a91884678 Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Tue, 23 Sep 2025 15:32:24 -0400 Subject: [PATCH] NButton: Simplified by removing the press state which was causing issues with Popups opening hover the button --- Widgets/NButton.qml | 34 +++++++++++----------------------- Widgets/NInputAction.qml | 1 - 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/Widgets/NButton.qml b/Widgets/NButton.qml index 7dc8841c5..e80b6b314 100644 --- a/Widgets/NButton.qml +++ b/Widgets/NButton.qml @@ -13,7 +13,6 @@ Rectangle { property color backgroundColor: Color.mPrimary property color textColor: Color.mOnPrimary property color hoverColor: Color.mTertiary - property color pressColor: Color.mSecondary property bool enabled: true property real fontSize: Style.fontSizeM * scaling property int fontWeight: Style.fontWeightBold @@ -38,8 +37,6 @@ Rectangle { color: { if (!enabled) return outlined ? Color.transparent : Qt.lighter(Color.mSurfaceVariant, 1.2) - if (pressed) - return pressColor if (hovered) return hoverColor return outlined ? Color.transparent : backgroundColor @@ -113,7 +110,7 @@ Rectangle { if (!root.enabled) return Color.mOnSurfaceVariant if (root.outlined) { - if (root.pressed || root.hovered) + if (root.hovered) return root.textColor return root.backgroundColor } @@ -153,33 +150,24 @@ Rectangle { } onExited: { root.hovered = false - root.pressed = false if (tooltipText) { tooltip.hide() } } onPressed: mouse => { - root.pressed = true + if (tooltipText) { + tooltip.hide() + } + if (mouse.button === Qt.LeftButton) { + root.clicked() + } else if (mouse.button == Qt.RightButton) { + root.rightClicked() + } else if (mouse.button == Qt.MiddleButton) { + root.middleClicked() + } } - onReleased: mouse => { - root.pressed = false - if (tooltipText) { - tooltip.hide() - } - if (!root.hovered) { - return - } - if (mouse.button === Qt.LeftButton) { - root.clicked() - } else if (mouse.button == Qt.RightButton) { - root.rightClicked() - } else if (mouse.button == Qt.MiddleButton) { - root.middleClicked - } - } onCanceled: { - root.pressed = false root.hovered = false if (tooltipText) { tooltip.hide() diff --git a/Widgets/NInputAction.qml b/Widgets/NInputAction.qml index 5b3706eb8..abe03961b 100644 --- a/Widgets/NInputAction.qml +++ b/Widgets/NInputAction.qml @@ -47,7 +47,6 @@ RowLayout { backgroundColor: Color.mSecondary textColor: Color.mOnSecondary hoverColor: Color.mTertiary - pressColor: Color.mPrimary enabled: root.actionButtonEnabled onClicked: {