mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
Show focus for NativeComboBox
This commit is contained in:
parent
0cfeec1a31
commit
e2aeb56263
3 changed files with 10 additions and 2 deletions
|
@ -10,6 +10,7 @@ use super::*;
|
|||
#[pin]
|
||||
pub struct NativeComboBox {
|
||||
pub enabled: Property<bool>,
|
||||
pub has_focus: Property<bool>,
|
||||
pub pressed: Property<bool>,
|
||||
pub has_hover: Property<bool>,
|
||||
pub is_open: Property<bool>,
|
||||
|
@ -94,6 +95,7 @@ impl Item for NativeComboBox {
|
|||
let text: qttypes::QString =
|
||||
this.current_value().as_str().into();
|
||||
let enabled = this.enabled();
|
||||
let has_focus = this.has_focus();
|
||||
let has_hover = this.has_hover();
|
||||
cpp!(unsafe [
|
||||
painter as "QPainterPtr*",
|
||||
|
@ -103,6 +105,7 @@ impl Item for NativeComboBox {
|
|||
size as "QSize",
|
||||
down as "bool",
|
||||
is_open as "bool",
|
||||
has_focus as "bool",
|
||||
has_hover as "bool",
|
||||
dpr as "float",
|
||||
initial_state as "int"
|
||||
|
@ -122,6 +125,9 @@ impl Item for NativeComboBox {
|
|||
} else {
|
||||
option.palette.setCurrentColorGroup(QPalette::Disabled);
|
||||
}
|
||||
if (has_focus) {
|
||||
option.state |= QStyle::State_HasFocus | QStyle::State_KeyboardFocusChange | QStyle::State_Item;
|
||||
}
|
||||
if (has_hover) {
|
||||
option.state |= QStyle::State_MouseOver;
|
||||
}
|
||||
|
|
|
@ -501,6 +501,7 @@ export component NativeTableHeaderSection {
|
|||
export component NativeComboBox {
|
||||
in-out property <string> current_value;
|
||||
in property <bool> enabled: true;
|
||||
in property <bool> has-focus;
|
||||
//-is_internal
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@ import { ComboBoxBase } from "../common/combobox-base.slint";
|
|||
export component ComboBox inherits NativeComboBox {
|
||||
in property <[string]> model <=> i-base.model;
|
||||
in-out property <int> current-index <=> i-base.current-index;
|
||||
out property has-focus <=> i-base.has-focus;
|
||||
|
||||
callback selected <=> i-base.selected;
|
||||
|
||||
enabled: true;
|
||||
has-focus: i-base.has-focus;
|
||||
accessible-role: combobox;
|
||||
accessible-value <=> root.current-value;
|
||||
current-value: root.model[root.current-index];
|
||||
|
@ -53,4 +53,5 @@ export component ComboBox inherits NativeComboBox {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue