Closed marcelloh closed 3 years ago
I don't quit understand your question. What are you trying to do?
somewhere i have this:
g.ListBox("ListBox1", records).OnChange(func(l int) { fmt.Printf("Clicked %s\n", records[l]) }),
but when I want to know which one is clicked/selected or whatever, and I want to select the first one, then I have to click on another first and then click on the first with the OnChange. I can do it with the OnDClick, but then I always have to click twice (which is nit nice for the user), so if there is a listbox, how can I handle it so I can immediately select/click whatever on the first, whithout the 2 disadvantages I just mentioned. It seems to me, this must be something like OnClick()
@marcelloh I still cannot understand clearly about your case.
As my understanding, there are two cases you just mentioned.
You want to set selected item, say set selected item to the first one. For this case, current listbox doesn't support.
You want to know user selected the first item. For this case, you can know the selected item's index from OnChange event.
Let me try to explain differently I have a list of items and I want the user to select one by clicking once. Is there such a possibility? Something like a HTL select
@marcelloh Select one by clicking once. OnChange is enough. If you are saying that the first item should be selected by default, and related event should be triggered, you could load the data related to first item after window is loaded, and load data related to other item in OnChange event.
Your solution is not the same. What if the action is to delete the selected item. It means that in your case the first item is always deleted. It needs to be a user action and NOT a system action, so a user is responsible for the action.
@marcelloh For the user need to delete a item, use context menu is a better choice.
Now there is only an OnDClick function I can do it with OnChange, but then I have to select another item first before I can select the first item. I think that an OnClick would fix this