Preserve NoScrollComboBox focus policy on macOS
This commit is contained in:
parent
2c1d363925
commit
256f6eed54
2 changed files with 14 additions and 0 deletions
|
@ -13,6 +13,8 @@ public:
|
||||||
void setTextItem(const QString &text);
|
void setTextItem(const QString &text);
|
||||||
void setNumberItem(int value);
|
void setNumberItem(int value);
|
||||||
void setHexItem(uint32_t value);
|
void setHexItem(uint32_t value);
|
||||||
|
void setEditable(bool editable);
|
||||||
|
void setLineEdit(QLineEdit *edit);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setItem(int index, const QString &text);
|
void setItem(int index, const QString &text);
|
||||||
|
|
|
@ -22,6 +22,18 @@ NoScrollComboBox::NoScrollComboBox(QWidget *parent)
|
||||||
this->setValidator(validator);
|
this->setValidator(validator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// On macOS QComboBox::setEditable and QComboBox::setLineEdit will override our changes to the focus policy, so we enforce it here.
|
||||||
|
void NoScrollComboBox::setEditable(bool editable) {
|
||||||
|
auto policy = focusPolicy();
|
||||||
|
QComboBox::setEditable(editable);
|
||||||
|
setFocusPolicy(policy);
|
||||||
|
}
|
||||||
|
void NoScrollComboBox::setLineEdit(QLineEdit *edit) {
|
||||||
|
auto policy = focusPolicy();
|
||||||
|
QComboBox::setLineEdit(edit);
|
||||||
|
setFocusPolicy(policy);
|
||||||
|
}
|
||||||
|
|
||||||
void NoScrollComboBox::wheelEvent(QWheelEvent *event)
|
void NoScrollComboBox::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
// Only allow scrolling to modify contents when it explicitly has focus.
|
// Only allow scrolling to modify contents when it explicitly has focus.
|
||||||
|
|
Loading…
Reference in a new issue