gofyne

Images in widget.NewGridWrap don't trigger selection as expected


I'm following the Fyne Demo, specifically the GridWrap widget, as a close reference to what I'm trying to achieve: namely a grid of elements that can be clicked for further action.

I've managed to tweak the example to use an widget.Icon extension plus a fixed MinSize value to get the look I'm after. My issue is that the elements in the Grid don't get consistently selected on click: a tiny area seems to be the only responsive one:

enter image description here

unlike the example in the Fyne Demo app:

enter image description here

There's an additional inquiry: I'm playing around with the scroll offset, and I've noticed there's some lag. My images were initially close to 1.5MB each and the scroll lag was effectively freezing any interaction for seconds. Since then, I've reduced the images to 10% of the original size and it's gotten much better, but there's still some lag. Is there a way to improve the interaction? My images are being loaded from static resources.

I've included a ZIP with all the code for reproduction. Thanks for any insight!

enter image description here


Solution

  • Is the custom widget you have added Tappable? If so it will be swallowing the events that cause selection, as the GridWrap no longer gets tapped on those areas.

    If that is the case then the best think might be to call GridWrap.Select(...) from inside your tappable child widget.