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

.nodes failing on list items in dynamic_list #69

Closed
geidnert opened this issue Nov 18, 2021 · 3 comments
Closed

.nodes failing on list items in dynamic_list #69

geidnert opened this issue Nov 18, 2021 · 3 comments

Comments

@geidnert
Copy link

Have a new interesting error, i use a gooey dynamic_list with x number of item rows in it, i want to find out on what element inside one list item i have clicked on, for example a delete button, so i use

if gui.pick_node(list.items[list.selected_item].nodes[hash(“giftitem/delete_btn”)], action.x, action.y)

inside the gooey dynamic_list function, and it works fine for item 1 to 9, but number 10 and above fails, and it looks like it is the .nodes that doesnt work when i debug printed out them like you se in the picture here

i made an example based on the gooey example project, and maybe the errors are coming as soon as i scroll the list and try to click on an scene object in one list item. So in the project i include it looks like it start failing on item nr 6

gooey-list_error.zip

@britzl britzl closed this as completed in b56f86e Nov 18, 2021
@britzl
Copy link
Owner

britzl commented Nov 18, 2021

The problem here is that it's a dynamic list, which means that it doesn't have one list item per element in the list. Instead it has just enough list item nodes to cover the visible area of the list and these items are reused.

The list.selected_item gives you an index into the list data, not an index into list.items.

The solution is to change list.selected_item to return the actual item structure (ie table containing index, root, nodes etc).

This is a breaking change and the version change will reflect this.

@geidnert
Copy link
Author

geidnert commented Nov 18, 2021

Ok, is this something that you think would make sense to change or am i using it all wrong? will you make a new major version of the camera extension if you think so?

@britzl
Copy link
Owner

britzl commented Nov 18, 2021

I've made the change already. Please try the new version.

With the new version list.selected_item is now the full item table with values root, nodes, index etc

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