Fix bug with dropdown

This commit is contained in:
Zander Otavka 2016-07-20 13:07:45 -07:00
parent 4a11e4accc
commit 5394c092d0

View file

@ -117,19 +117,22 @@ FocusScope {
function showList() {
var r = desktop.mapFromItem(root, 0, 0, root.width, root.height);
listView.currentIndex = root.currentIndex
scrollView.x = r.x;
scrollView.y = r.y + r.height;
var bottom = scrollView.y + scrollView.height;
var y = r.y + r.height;
var bottom = y + scrollView.height;
if (bottom > desktop.height) {
scrollView.y -= bottom - desktop.height + 8;
y -= bottom - desktop.height + 8;
}
scrollView.x = r.x;
scrollView.y = y;
popup.visible = true;
popup.forceActiveFocus();
listView.currentIndex = root.currentIndex;
scrollView.hoverEnabled = true;
}
function hideList() {
popup.visible = false;
scrollView.hoverEnabled = false;
}
FocusScope {
@ -161,6 +164,7 @@ FocusScope {
id: scrollView
height: 480
width: root.width + 4
property bool hoverEnabled: false;
style: ScrollViewStyle {
decrementControl: Item {
@ -193,7 +197,8 @@ FocusScope {
delegate: Rectangle {
width: root.width + 4
height: popupText.implicitHeight * 1.4
color: popupHover.containsMouse ? hifi.colors.primaryHighlight : (isLightColorScheme ? hifi.colors.dropDownPressedLight : hifi.colors.dropDownPressedDark)
color: (listView.currentIndex === index) ? hifi.colors.primaryHighlight :
(isLightColorScheme ? hifi.colors.dropDownPressedLight : hifi.colors.dropDownPressedDark)
FiraSansSemiBold {
anchors.left: parent.left
anchors.leftMargin: hifi.dimensions.textPadding
@ -206,9 +211,9 @@ FocusScope {
MouseArea {
id: popupHover
anchors.fill: parent;
hoverEnabled: true
hoverEnabled: scrollView.hoverEnabled;
onEntered: listView.currentIndex = index;
onClicked: popup.selectSpecificItem(index)
onClicked: popup.selectSpecificItem(index);
}
}
}