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