Add hasCursor + hovered surface to four kit primitives

This commit is contained in:
Ryan Hughes
2026-05-18 01:31:37 -04:00
parent 23f1ba1b3f
commit 91a87470a2
5 changed files with 95 additions and 15 deletions
@@ -34,7 +34,23 @@ Item {
property int popupMinHeight: 220
property bool showLabel: true
// Panel-cursor flag. When true, the trigger renders the same focus ring
// as Tab-focus so a panel's keyboard cursor lands here identically.
// Emits `hovered(bool)` on pointer enter/leave so the panel can keep
// its cursor state in sync with the mouse.
property bool hasCursor: false
// popupOpen + open()/close()/toggle() let a parent panel know when the
// dropdown owns keys (search field + result list are active) and
// suspend its own keyCatcher so typing into the filter doesn't drive
// the panel cursor.
readonly property bool popupOpen: popup.opened
function open() { popup.open() }
function close() { popup.close() }
function toggle() { popup.opened ? popup.close() : popup.open() }
signal changed(string value)
signal hovered(bool isHovered)
function optionValue(o) {
return (o && typeof o === "object") ? String(o.value) : String(o)
@@ -88,15 +104,22 @@ Item {
width: parent.width
height: root.rowHeight
radius: Style.cornerRadius
readonly property bool _focused: trigger.activeFocus || root.hasCursor
color: Qt.rgba(root.foreground.r, root.foreground.g, root.foreground.b,
trigger.activeFocus ? 0.08 : 0.04)
border.color: trigger.activeFocus
trigger._focused ? 0.08 : 0.04)
border.color: trigger._focused
? Style.focusBorderColor
: Qt.rgba(root.foreground.r, root.foreground.g, root.foreground.b, 0.4)
border.width: trigger.activeFocus ? Style.focusBorderWidth : 1
border.width: trigger._focused ? Style.focusBorderWidth : 1
activeFocusOnTab: true
HoverHandler {
onHoveredChanged: root.hovered(hovered)
}
Keys.onPressed: function(event) {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter
|| event.key === Qt.Key_Space || event.key === Qt.Key_Down) {