B4A Library [B4X] [XUI] [B4XLib] HintOverlay - display hints that also highlight target views

Highlight B4XViews and display your text captions with a connecting line.

For use in B4A, B4J, B4i.
Copy b4xlib file to: \B4X Additional Libraries\B4X.

Custom styling options:
  • BackgroundAlpha (transparency of the hint screen overlay)
  • CaptionColor (base color of the caption box)
  • TextColor
  • TextSize
  • OutlineColor (includes; caption outline, connecting line and target highlight color)
  • HighlightTargetView (display or hide the target outline)
  • ClearTargetView (cuts-out the target view through the overlay tint)
  • MaxDisplayTime (maximum time in milliseconds that hints are displayed if user does not tap screen – Default value is 0 (disabled))
Version 1.20
- Added MaxDisplayTime property, which automatically moves on to the next hint when the user has not tapped the screen within the set amount of time (milliseconds).

Version 1.10
- Added ClearTargetView property, which exposes the target view through the tint when set to True (many thanks to @Blueforcer for the great idea and coding modification)
- The Show method now supports Wait For - very useful if you need to change styling properties between hints.

Version 1.00
- Release

Hints are added to a queue using Show(myB4XView, "My text"), and the hint overlay is removed after all hints in the current queue have been viewed.

Usage:
Sub Class_Globals
    Private Hints As HintOverlay
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Hints.Initialize(Root)
End Sub

Private Sub B4XPage_Resize (Width As Int, Height As Int)
    Hints.Base_Resize(Width,Height)
End Sub

Private Sub ShowHints
'Set HintOverlay style (where required)
    Hints.BackgroundAlpha=80
    Hints.CaptionColor=xui.Color_ARGB(120,0,0,0)
    Hints.TextColor=xui.Color_White
    Hints.OutlineColor=xui.Color_Red

'Call Hints.Show(myB4XView, "My text”)
    Hints.Show(Label1,"This is a label”)
    Hints.Show(Button1,"This is a button”)
End Sub
 

Attachments

  • HintOverlayExample 1.10.zip
    46.8 KB · Views: 542
  • 01.png
    01.png
    11.6 KB · Views: 907
  • 02.png
    02.png
    12.9 KB · Views: 917
  • 03.png
    03.png
    11.9 KB · Views: 837
  • 04.png
    04.png
    12.3 KB · Views: 888
  • HintOverlay.b4xlib
    7.4 KB · Views: 544
Last edited:

Segga

Member
Licensed User
Longtime User
You could overcome this by placing a transparent panel above the ScrollView and over the view that you want to highlight.
You would have to calculate where in the scroll view the the item that you want to highlight is and add appropriate adjustments.
It is possible.
 

Jerryk

Active Member
Licensed User
Longtime User
I'm contacting the author. I got this error in Crashlytics.
B4X:
Caused by java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
       at java.util.ArrayList.get(ArrayList.java:437)
       at anywheresoftware.b4a.objects.collections.List.Get(List.java:117)
       at cz.flashcards3000.hintoverlay$ResumableSub_DisplayInstruction.resume(hintoverlay.java:235)
       at cz.flashcards3000.hintoverlay._displayinstruction(hintoverlay.java:177)
       at cz.flashcards3000.hintoverlay$ResumableSub_Show.resume(hintoverlay.java:742)
       at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1748)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:201)
       at android.os.Looper.loop(Looper.java:288)
       at android.app.ActivityThread.main(ActivityThread.java:7870)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1009)
 

Segga

Member
Licensed User
Longtime User
Looks like the hints are being called too early. Try showing your hints at the end of B4XPage_Appear or add a Sleep(500) before setting up/showing hints.
 

Jerryk

Active Member
Licensed User
Longtime User
Unfortunately, it didn't help. I put the ShowHints procedure at the end of B4XPage_Created. I put Sleep(500) before calling Show. The error doesn't occur on my devices, only during internal verification in Google Play Console does the error occur on some Pixel 6 Pro.
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
....
    showHints
End Sub

Private Sub showHints
    If Starter.kvs.GetDefault("HintMain", False) = False Then
        Sleep(500)
        Hints.BackgroundAlpha = 99
        Hints.CaptionColor=xui.Color_Yellow
        Hints.OutlineColor=xui.Color_Yellow
        Hints.TextColor=xui.Color_Black
        Hints.HighlightTargetView=True
        Hints.Show(B4XComboBox1.mBase,Starter.loc.Loc("h_m_course"))
        Hints.Show(cbLearn, Starter.loc.Loc("h_m_learn"))
        Hints.Show(cbTest, Starter.loc.Loc("h_m_test"))
        Hints.Show(btMenu, Starter.loc.Loc("h_m_menu"))
        Starter.kvs.Put("HintMain", True)
    End If
End Sub

I am attaching a statement from Crashlytics
 

Attachments

  • cz.flashcards3000_issue_3a20ec035d63905bf4908616c74ad02f_crash_session_67CFBC82027100010C46779...txt
    10.5 KB · Views: 86

Segga

Member
Licensed User
Longtime User
Unfortunately, it didn't help. I put the ShowHints procedure at the end of B4XPage_Created. I put Sleep(500) before calling Show. The error doesn't occur on my devices, only during internal verification in Google Play Console does the error occur on some Pixel 6 Pro.
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
....
    showHints
End Sub

Private Sub showHints
    If Starter.kvs.GetDefault("HintMain", False) = False Then
        Sleep(500)
        Hints.BackgroundAlpha = 99
        Hints.CaptionColor=xui.Color_Yellow
        Hints.OutlineColor=xui.Color_Yellow
        Hints.TextColor=xui.Color_Black
        Hints.HighlightTargetView=True
        Hints.Show(B4XComboBox1.mBase,Starter.loc.Loc("h_m_course"))
        Hints.Show(cbLearn, Starter.loc.Loc("h_m_learn"))
        Hints.Show(cbTest, Starter.loc.Loc("h_m_test"))
        Hints.Show(btMenu, Starter.loc.Loc("h_m_menu"))
        Starter.kvs.Put("HintMain", True)
    End If
End Sub

I am attaching a statement from Crashlytics
It could be that the IndexOutOfBoundsException is caused because the B4XComboBox hasn't loaded yet.
I would try putting invisible panels exactly where your combo boxes are and highlighting those invisible panels - I hope this suggestion works for you.
 

Jerryk

Active Member
Licensed User
Longtime User
Even replacing B4XComboBox with an invisible panel didn't help. On another review, the same error in Crashlytics. I think lstHints.Get(0) reads a B4XView object that doesn't exist yet, which causes the error. Maybe it would be a good idea to put these lines at the beginning of the Show procedure? :
Do While Not(TargetView.IsInitialized)
Sleep(50)
Loop
 
Top