B4J Question [ABMATERIAL] Can a Container Column have a hover event?

Cableguy

Expert
Licensed User
Longtime User
Well... just like the title says...

Any one knows?
 
Same way as the button hover, with the ABMBANano library:

As you seem to have trouble finding the correct ID, here I use another trick by (ab)using the .B4JSUniqueKey property of a component:
Code: Copy
' in BuildPage add a cell pointer theme (setting clickable will give it a finger pointer cursor)
theme.AddCellTheme("pointer")
theme.Cell("pointer").Clickable = True

' in ConnectPage
    ...
    Dim tempcont As ABMContainer
    tempcont.Initialize(Page, Name & "tempCont1", "")
    tempcont.AddRow(1,True,"","")
    tempcont.BuildGrid
 
    Dim tempcont2 As ABMContainer
    tempcont2.Initialize(Page, Name & "tempCont2", "")
    tempcont2.AddRow(1,True,"","")
    tempcont2.BuildGrid

    tempcont2.Cell(1,1).UseTheme("pointer")
    tempcont2.cell(1,1).B4JSUniqueKey = "MyUnique1"  '<------------------------ give this container cell  a unique key
 
    Dim templbl As ABMLabel
    templbl.Initialize(Page, Name & "hovertest", "To give the container some content", ABM.SIZE_PARAGRAPH, True, "")
    tempcont2.Cell(1,1).AddComponent(templbl)
 
    tempcont.Cell(1,1).AddComponent(tempcont2)
    Page.NavigationBar.ExtraContent.Cell(1,1).AddComponent(tempcont)

Then AFTER the page has been refreshed and the containers have been added:
Code: Copy
    page.Refresh

    ' get the ID from the B4JSUniqueKey
    Dim HoverID As String = GetIDFromUniqueKey("MyUnique1")

    Dim MyJS As ABMHover
    MyJS.Initialize(ws, "myJS")
    MyJS.AddHover(ws, HoverID)
 
    'page.ShowCookiesMessage(FieldNames.Get("gdpr"), "2f3033", "FFFFF", "ff9800", "000000", "444444", FieldNames.Get("gdprAccept"), FieldNames.Get("gdprMoreInfo"), "#", 365)
    page.ShowCookiesMessage(FieldNames.Get("gdpr"), "2f3033", "FFFFF", "ff9800", "000000", "444444", FieldNames.Get("gdprAccept"), "", "#", 365)
End Sub

' the event
Sub MyJS_Hover(ID As String, IsOver As Boolean)
    Log(ID & " Is Over: " & IsOver)
End Sub

' retrieve the ID from the B4JSUniqueKey you've previously set on creation
public Sub GetIDFromUniqueKey(uniqueKey As String) As String
    Dim script As String = $"return $("[data-b4js='${uniqueKey.ToLowerCase}']").attr('id');"$
    Dim ret As Future = page.ws.EvalWithResult(script, Null)
    Return ret.Value
End Sub

Alwaysbusy
 
Last edited:
Upvote 0
Back
Top