B4J Question ScrollBar on TextArea

micro

Well-Known Member
Licensed User
Hi to all
there is a way to know if the scrollbar is visible in a textarea?
Thanks
 

Erel

Administrator
Staff member
Licensed User
Code to monitor visibility changes:
B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private TextArea1 As TextArea
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("1") 'Load the layout file.
    MainForm.Show
    Dim jo As JavaObject = TextArea1
    MonitorSrollbar(jo.RunMethod("lookup", Array(".scroll-bar:vertical")))
End Sub

Sub MonitorSrollbar (Scrollbar As Node)
    Dim CurrentValue As Boolean = Scrollbar.Visible
    Do While True
        If CurrentValue <> Scrollbar.Visible Then
            CurrentValue = Scrollbar.Visible
            Log("Scrollvar visibility changed: " & CurrentValue)
        End If
        Sleep(100)
    Loop
End Sub

If you only need to get the current state:
B4X:
Sub IsScrollbarVisible (ta As TextArea) As Boolean
    Dim jo As JavaObject = ta
    Dim n As Node = jo.RunMethod("lookup", Array(".scroll-bar:vertical"))
    Return n.Visible
End Sub
 
Upvote 0
Top