If you place a ComboBox
on a Flickable
, you may unhappily notice that ComboBox
steals your mouse wheel events on Flickable
.
I think an UI component like ComboBox
which accepts mouse wheel event is totally a stupid idea and a great anti-pattern of UI/UX (the value of ComboBox is quite easily to be accidently modified). However, the API of QtQuick Controls, no matter 1 or 2, are totally moron. They totally don’t provide any API to deal with a lot of shit. So you have to workaround it:
1 | // MyComboBox.qml |
Explanation
- When component is loaded and instantialized (
Component.onCompleted
), use awhile
loop find any parent component hasflick
attribute. If found, assign_flickableItem
property as it. - Place a
MouseArea
to “steal the wheels events back”, which invoke_flickableItem.flick()
whenonWheel
.