Best Way to Implement This?
-
I've got an array of dynamically-generated panels (green boxes) inside of a viewport, inside a container panel. I'd like to have a single mouse callback for when users click on a green panel—and to know which panel was clicked. The viewport is to accommodate cases where the number of dynamic panels exceeds the space to draw them.
Any ideas?
Cheers.
-
@clevername27 probably child panels is the way to go here, check out the six state button example
-
@HISEnberg Thanks man. I am indeed using child panels—good thought. I guess I'm wondering if it's a good idea simply to assign the same callback function to all of them. (Is there overhead with that? Etc.) Cheers.
-
@clevername27 You can get the parent panel's child panel list, and use index of, to find the index of the child panel in the array.
-
@clevername27
I am afraid that one child = one CB...NON-SENSE EXPLAINED BELOW BY @d-healey
Or...
If you're concerned about this, why not dropping the child panel paradigm for an object where you create "virtual children" and draw zones in one unique panel? You can then detect the click position, deduce the area and the corresponding virtual child.
I guess it depends on the complexity the children have to deal with. but if it's just for displaying simple stuff it might be very efficient. -
@ustk This is what I was referring to. You can calculate "zones" corresponding to the child panels, though this might be less efficient then just adding new panels in.
-
@HISEnberg oh yes I haven't clicked but I remember when that six state button thing was published
I do think it is more efficient, especially if you have a lot of child panels, that would clutter the interface components (even if they don't appear in the list, they're still components)That would be a good candidate for the new Profiler
Here's a snippet
HiseSnippet 1549.3ocsWssbaaCDEzwLMR8xzjoO2AidHCUrirjksysdw1x1IdZbrlH2bY73IEhDTD0P.pffVVSF+Gzm6WR+.5i8yo+AsK.ojntT6DOs5AIsD6kC1cwhCapj9z3XoB4T7nA8nHmOys0.gNpQDgIP6uCx4NtM3zynpFQLdPShfxQaOnGINlFfbbtwSM54TXQj8ye88aS3DgOc7iPnWIY9zmy5xzieZyM+AFmuGIfdDqaNsWay88khFRtLAvzMbqh5Q7Okzg9BhQsEbQOiDGgbtmasG9HexZ9quQM5Zs2H3AAaz1+g90CI0Cdz5j51+tQ850QN2b2.lVpZoIZZL3zskACZEI6KRCvqXwr1bpQnFpED4zGiR2vCSPwHjyhMGmttQZ55qbOfEvF87wosuzt.drE4SZNKbYPp1GAjbxAoESgzsca4qX8ziWwfmO0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EnrrJPwXgLDBppsDLtSFACZvqXz98jJMhEXXXLTrFxtIxyADMsS9hLmrssoz5fa4lVVli0+396.2La36jgK.q8nJMyjRb1gdFvvLk8SA2cnwmpk8r.Oqc.RaevP+7wAls4f7B8MmPQNtN+IHldK8PICtFEqakFqOeHOLKm4zvLZXY9vfPCxKjpSN+kGcivvumCCEt4WmY6jLnLXHGCJSQXjSKb0kgwP7O34xDa9SaxhOPZlAQTvicVfJHPKngu6yANgBCsxQ37WmHW4ARZ35Unf3ZlIAuHvL7WAlyxfDNQOIcZyKZjs.bvYBNrFdp.UN8f7uHxGAG6pWJG6OTHda2lLsez7w3ByAilyV+Ofwr2L4yc2MLDnJMFfK5t2attuFxUD9Tdjcfa.TLnsw8EIcaATd7oPzEP6ero3ufYLPpbUirICzhJBrB+M7IawZFYmrEqMbQTWBb0667SmiXd2maYeBfIg8cCK3dfQFOmoOcgVy246OoqlwvUutFV+5Z3ZWWCW+5Z3FWWCev00vGd0FZlbrUhV1M8XCBcPycsy6cb10NZw1sh9G.azGzJC
-
@ustk I am experiencing some buggy behaviour with child panels in a recent project release. I will have to isolate it further and test it but nothing is jumping out at me for how long it takes to register mousecallbacks and repainting the child panels.
-
@ustk said in Best Way to Implement This?:
I am afraid that one child = one CB...
You can apply the same callback function to all child panels, so it's not any extra work. Then you can get the index from the array.
@clevername27 If they're just boxes you might want to use the viewport in table mode instead of using panels.
-
@clevername27 Mouse Broadcaster, and you can dynamically add or remove components to it. You can define one (or more) callbacks, and add or remove them, and in them simply filter for a component. The function will report the component which triggered the broadcaster.
-
Just to continue on my idea (but I understand the whole possibilities you guys are raising) here's the same example as above with a slider in the virtual children
HiseSnippet 1761.3ocsXssaabCDcWmrAQpMEMA8gh9PAgdHXUrirjkujK8hskcZLZbhPrqSBLLRo1kRKSnHU4RYYg.+GzOm9AzG6mS+CZmg6JsqjksSLZ0CxZHmKGNblgy3lZU.KNVocbKt+vdLG2O2augRSTiHJW5ryVNt2wqgfcLS2HhKBaRkLgyl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+KPn+wYd
-
@ustk @HISEnberg @aaronventure @d-healey Thanks, guys!!!!
-
C clevername27 has marked this topic as solved
-
@clevername27 I can't wait to see what you are working on! I am quite interested when you reveal details about your project, even just technical bits like this on using dynamic child panels.
-
@VirtualVirgin I appreciate the enthusiasm. When I do take the wraps off, I'm following @d-healey's lead, and releasing the rest of my code to the community. Let me know if there's something specific you'd like.
-
@clevername27 said in Best Way to Implement This?:
@VirtualVirgin I appreciate the enthusiasm. When I do take the wraps off, I'm following @d-healey's lead, and releasing the rest of my code to the community. Let me know if there's something specific you'd like.
Thank you! When I have enough experience, I would like to contribute as well.