Hi, I have an activity wich draws a Heatmap, I need to detect in which rectangle the user clicks on.
The rectangles shape and position changes depending on the stocks data.
And the map can be scrolled up and down.
How can I do it?
See attached image.
Thaks
If for instance this drawing is on a Panel, you could use Panel_OnTouch() event (which gives you the touch coordinates) and handle ACTION_DOWN and ACTION_UP to decide when it is clicked
Sub PanelMap_OnTouch(Action As Int, X As Float, Y As Float)
'If Action = Activity.ACTION_UP Then
Msgbox(Action&" "&X&" "&Y,"")
'End If
End Sub
Sub Pane1_OnTouch(Action As Int, X As Float, Y As Float)
'If Action = Activity.ACTION_UP Then
Msgbox(Action&" "&X&" "&Y,"")
'End If
End Sub
PanelMap is a Panel inside Panle1 but this does not work, the events are not generated.
It should work if it is initialized with the proper event name
B4X:
PanelMap.initialize("PanelMap")
and there is no other view on it which can consume a touch/click event. For instance if this panel has imageviews on it, they should be initizalized void
B4X:
IV.initialize("") 'for all the views contained in panelmap or added later to Panel1