B4A Library [Code Module] HotSpots

[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:

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

  • hotspot1.5.zip
    10 KB · Views: 474
  • hotspot1.6.zip
    10.7 KB · Views: 611
Last edited:

stevel05

Expert
Licensed User
Longtime User
OK, I think that due to putting the touch subroutine in front of the click handler on the scroll view the timings may be messed up and the scroll view may not register the double click, you may have to handle the double click within the touch sub.

Try catching the required info (the selected item from the scroll view) on the first click and set a timer in the touch sub, then if a double click is found (within say 500ms) call the contact from the touch sub, of no double click proceed as normal.

Let me know how you get on, I may have some time to look at it tomorrow or Friday if it's still a problem.

Steve
 

laviniut

Active Member
Licensed User
Longtime User
Is a good idea. but in sub
B4X:
Sub Listcont_ItemClick (Position As Int, Value As Object)
    Log("value="&Value)
End Sub
i cannot get anything from list view.
maybe with some sort of reflection?
 

stevel05

Expert
Licensed User
Longtime User
@laviniut, you're going to kick yourself, you have initialized Listcont as:

B4X:
Listcont.Initialize("listcontview")

The ItemClick sub should be:

B4X:
Sub listcontview_ItemClick (Position As Int, Value As Object)

Then you get the value returned.

Steve
 

laviniut

Active Member
Licensed User
Longtime User
stevel05, can you help me? now i can get item from listcontview but i failed with timers.
i cannot get correct doubleclick item from listview.
 

Attachments

  • contacts for blind final hotspot list work.zip
    43.4 KB · Views: 273

stevel05

Expert
Licensed User
Longtime User
@laviniut

I've had a quick look at your app, if you check the ResultsList you are getting two results, which is causing problems with the double click check. You need to initialize SLHotSpotLib regardless of whether it is already initialized, as you are getting results from hotspots from the previous activity.

Then you'll have a chance to get the double click to work.

Steve
 

laviniut

Active Member
Licensed User
Longtime User
I've initialized again SLHotSpotLib and is working now. And i finished application. Was a minor problem because
B4X:
Sub listcontview_ItemClick (Position As Int, Value As Object)
is slow than
B4X:
Sub DoubleClickedalege(Tag As String)
so i needed a delay, but i solved it.
Thank you very much Steve.
 

stevel05

Expert
Licensed User
Longtime User
You're welcome, I'm glad you've got it working it's a good concept.
 

Beja

Expert
Licensed User
Longtime User
Very old thread but...
Thanks for sharing..

When the top value is 0 then the variable is float.. in all other cases it is integer.
 
Top