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

ScrollView onValueChanged description doesn't match real behavior #137

Open
socantre opened this issue Sep 4, 2021 · 0 comments
Open

ScrollView onValueChanged description doesn't match real behavior #137

socantre opened this issue Sep 4, 2021 · 0 comments

Comments

@socantre
Copy link
Contributor

socantre commented Sep 4, 2021

docs/ui/layoutgrouping.md

The description of VerticalScrollView's onValueChanged attribute reads:

When a selection is made, its name is sent to a function with this name.

This makes it sound like a VerticalScrollView has some 'selection' which changes, and callback function is called whenever that selection changes (when a user selects something?). However instead I observe that the callback is called constantly when the VerticalScrollView is visible, the arguments given to the callback are a player, a string containing a couple of numbers which seem related to the ScrollView's scroll position and position, and the id of the ScrollView itself.

I'd like to create a UI that shows a list of items that the user can select from, sort of like a <Dropdown> but with a scrollable view. VerticalScrollView's docs make it sound like it could do the job but I haven't found how to make it work.

-- lua script

count = 0
function onValueChanged_listSelection(arg1, arg2, arg3, arg4)
  count = count + 1
  print(count, type(arg1), arg1, type(arg2), arg2, type(arg3), arg3, type(arg4), arg4)
end

-- UI xml snippet

<VerticalScrollView
  id="item_selection"
  onValueChanged="onValueChanged_listSelection"
  color="rgb(0,0,0)" minHeight="100" preferredHeight="200" flexibleHeight="100">
    <VerticalLayout id='layout'>
        <Panel id='panel1' minHeight="30"><Text id='line1'>1</Text></Panel>
        <Panel id='panel2' minHeight="30"><Text id='line2'>2</Text></Panel>
        <Panel id='panel3'><Text id='line3'>3</Text></Panel>
        <Panel id='panel4'><Text id='line4'>4</Text></Panel>
        <Panel id='panel5'><Text id='line5'>5</Text></Panel>
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

1 participant