[Code Module] Screen HotSpots
I was playing with my favorite new toy ArraySort, when I came up with this idea for a hotspot manager. It's really simple and only requires a Code Module, but I've seen some discussion around it on the forum so I thought I'd share it in case.
It doesn't require any libraries and is petty self explanatory.
You need to Add the existing module 'HotSpotLib' from the attached project which is a code module. Create a panel with a touch sub.
You then just need to create one or more HotSpots with:
Then Call the find routine from within the Panel_Touch sub:
I haven't tested it with too many hotspots, that comes next so if you get any problems let me know and I'll try to sort it.
There are no dependencies on additional Librarys.
If there are any suggestions for improvements, I'm only too happy to learn. Some of the search code may be a bit clunky, I don't use that too often.
For my own use, I will compile it to a library. But it's easier to share the source code this way and you can compile it if you want to.
V1.1 Added HotCircle
V1.2 Added FindHotSpotFirst,FindHotSpotLast, FindHotSpotAll
V1.3 Added Method IsInitialized
V1.4 Added Methods GetRectangle and ClearHotSpots
Removed DIP conversion from module, it should be specified in calls as required.
V1.5 bug Fix see post 14 I'm afraid this is a breaking fix and the module now needs to be initialized. HotSpotLib.Initialize
V1.6 Added Polygons
- draw routines
- fixed bugs and ommisions
I was playing with my favorite new toy ArraySort, when I came up with this idea for a hotspot manager. It's really simple and only requires a Code Module, but I've seen some discussion around it on the forum so I thought I'd share it in case.
It doesn't require any libraries and is petty self explanatory.
You need to Add the existing module 'HotSpotLib' from the attached project which is a code module. Create a panel with a touch sub.
You then just need to create one or more HotSpots with:
B4X:
HotSpotLib.AddHotSpot(10,10,60,70,"Tag1")
Then Call the find routine from within the Panel_Touch sub:
B4X:
Sub Panel1_Touch (Action As Int, X As Float, Y As Float)
If Action = Activity.ACTION_DOWN Then
Dim HS As HotSpotType = HotSpotLib.FindHotSpot(X,Y)
'If Hotspot is not found an uninitialized HotSpotType is returned.
If HS.IsInitialized Then
Log("X "&X&" Y "&Y&" "&HS.Tag)
End If
End If
End Sub
I haven't tested it with too many hotspots, that comes next so if you get any problems let me know and I'll try to sort it.
There are no dependencies on additional Librarys.
If there are any suggestions for improvements, I'm only too happy to learn. Some of the search code may be a bit clunky, I don't use that too often.
For my own use, I will compile it to a library. But it's easier to share the source code this way and you can compile it if you want to.
V1.1 Added HotCircle
V1.2 Added FindHotSpotFirst,FindHotSpotLast, FindHotSpotAll
V1.3 Added Method IsInitialized
V1.4 Added Methods GetRectangle and ClearHotSpots
Removed DIP conversion from module, it should be specified in calls as required.
V1.5 bug Fix see post 14 I'm afraid this is a breaking fix and the module now needs to be initialized. HotSpotLib.Initialize
V1.6 Added Polygons
- draw routines
- fixed bugs and ommisions
Attachments
Last edited: