Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access elements in a dropdown list? #7

Closed
qutab opened this issue Oct 31, 2019 · 2 comments
Closed

How to access elements in a dropdown list? #7

qutab opened this issue Oct 31, 2019 · 2 comments
Assignees

Comments

@qutab
Copy link

qutab commented Oct 31, 2019

In QML if I have a combobox e.g.:

ComboBox {
    objectName: "fruitCombo"
    anchors.bottom: parent.bottom
    width: 200
    model: [ "Banana", "Apple", "Coconut" ]
}

I can click the list using mouseClick("fruitCombo") but how can I click individual items in the list? e.g. the 3rd item or the item with text 'Coconut'. Would such functionality be easy to implement in spix?

@faaxm
Copy link
Owner

faaxm commented Nov 2, 2019

I had a quick look and I think finding the location of an item in the list is tricky, as they are generated dynamically.

I think an easier way would be to not go through mouse events, but change the currentIndex of the ComboBox directly.
In a way this is cheating, but since you probably don't want to test the functionality of the ComboBox itself, but rather that other components react to the change, this could be good enough.

The way to go would then be to add a SetProperty command to Spix, similar to the current GetProperty.
What do you think?

I might have some time next week to look into this, but of course you are also welcome to contribute ;)

@faaxm faaxm closed this as completed Nov 2, 2019
@faaxm faaxm reopened this Nov 2, 2019
@faaxm faaxm self-assigned this Nov 2, 2019
@faaxm
Copy link
Owner

faaxm commented Nov 30, 2019

@qutab I played around with this a bit and after introducing the "EnterKey" command, the best option seems to be to simulate keyboard events (arrow keys) to switch between the entries in a combo box.
It first has to be opened via a mouse click though...

You could also use the new "SetProperty" command to set the currently selected item, but his won't trigger the same notifications as a selection change done via the UI...

Have a look at the extended "ReapeaterLoader" example in the branch feature/ComboBox and let me know what you think ;-)

@faaxm faaxm closed this as completed Feb 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants