NButton: Simplified by removing the press state which was causing issues with Popups opening hover the button

This commit is contained in:
ItsLemmy
2025-09-23 15:32:24 -04:00
parent a2b57c5165
commit 9a9d68c78d
2 changed files with 11 additions and 24 deletions
+3 -15
View File
@@ -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
}
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
root.middleClicked()
}
}
onCanceled: {
root.pressed = false
root.hovered = false
if (tooltipText) {
tooltip.hide()
-1
View File
@@ -47,7 +47,6 @@ RowLayout {
backgroundColor: Color.mSecondary
textColor: Color.mOnSecondary
hoverColor: Color.mTertiary
pressColor: Color.mPrimary
enabled: root.actionButtonEnabled
onClicked: {