Description
I was thinking about how to make a displayio object touchscreen (and thus menu) compatible. In my work I add the object to a list of currently onscreen (and touchable) objects whenever it is 'placed' on the screen and remove when 'unplaced'. To me, this does not sound objecty like displayio is. so, upon further thought, i was thinking about how to make dispio object 'touchable' here are my thoughts and then my idea for implementation:
my thoughts on how to implement touch, in general, is to have a list of 'touch zone's whether the zones are the objects themselves or an instance of a touch zone class made by the touchable object. then when the screen is touched the list is scanned for any touch boxes that are around the point.
I was thinking about a solution and realized there is already a list of objects on the screen, the currently shown group. then all that needs to be known is which objects can be touched. i was thinking that adding a .touchable
boolean to shapes and such could achieve this. in the background, the touchscreen would be read then loop through the group(backward) to see which objects are touchable and have the point inside their space.
For shapes they have bounds and the point can be scanned for in there, text is square, and so are images (well rectangular).