B4J Question Find Vertical Scroll Bars (TableView vs SplitPane)

T201016

Active Member
Licensed User
Longtime User
It works fine for the TableView, and for the SplitPane it does not.
Is the method below correct?

Detail: SplitPane consists of two windows vertically separated.

FindVerticalScrollBars:
Private Sub FindVerticalScrollBars (sp As SplitPane) As JavaObject
    Dim jo As JavaObject = sp
    Dim bars() As Object = jo.RunMethodJO("lookupAll", Array(".scroll-bar")).RunMethod("toArray", Null)
    Log(bars.Length) 'error Length = 0
    For Each baro As JavaObject In bars
        Dim orientation As String = baro.RunMethod("getOrientation", Null)
        If orientation = "VERTICAL" Then
            Log("OK")
            Return baro
        End If
    Next
    Return Null
End Sub
 

Attachments

  • SplitPane.png
    SplitPane.png
    4.1 KB · Views: 24
Solution
Sub SetScrollPositionsEvent(...)

Quite a complicated procedure that examines the position of the Scroll-bar
for individual views inside SplitPane.

They are (views) of the type BBCodeView, TextArea -whitch have their own scroll-bar,
with individual positions.

Example:
Sub Class_Globals
#Region SplitPane Scroll-bar
    Type MySplitPane (MinValue As Double, MaxValue As Double, SetValue1 As Double, SetValue2 As Double, SetValue3 As Double, _
                      BBCodeView(7) As Double, taSourceCode(7) As Double, taNote(7) As Double, ScroolBar_Visible As Boolean)
    Public ssp As MySplitPane
#End Region
End Sub


'GlobalVariable = {1=BBCodeView1.mBase, 2=taSourceCode, 3=taNote}
'1=BBCodeView1.mBase As BBCodeView...

T201016

Active Member
Licensed User
Longtime User
Sub SetScrollPositionsEvent(...)

Quite a complicated procedure that examines the position of the Scroll-bar
for individual views inside SplitPane.

They are (views) of the type BBCodeView, TextArea -whitch have their own scroll-bar,
with individual positions.

Example:
Sub Class_Globals
#Region SplitPane Scroll-bar
    Type MySplitPane (MinValue As Double, MaxValue As Double, SetValue1 As Double, SetValue2 As Double, SetValue3 As Double, _
                      BBCodeView(7) As Double, taSourceCode(7) As Double, taNote(7) As Double, ScroolBar_Visible As Boolean)
    Public ssp As MySplitPane
#End Region
End Sub


'GlobalVariable = {1=BBCodeView1.mBase, 2=taSourceCode, 3=taNote}
'1=BBCodeView1.mBase As BBCodeView
'2=taSourceCode As B4XView
'3=taNote As B4Xview
'ssp.ScroolBar_Visible - True, if a vertical scroll-bar is visible
'EventName_ScrollPosition_Changed - Saves the scroll-bar position for the current object (see: GlobalVariable)
Private Sub SetScrollPositionsEvent(GlobalVariable As Int)
    Dim jo As JavaObject = IIf(GlobalVariable = 1, BBCodeView1.mBase, IIf(GlobalVariable = 2, taSourceCode, taNote))
    Dim bars() As Object = jo.RunMethodJO("lookupAll",Array(".scroll-bar")).RunMethod("toArray",Null)

    Dim SplitPaneScrollBar As JavaObject
   
    ssp.ScroolBar_Visible = False
   
    For Each sps As Object In bars
        Dim sbJO As JavaObject
        sbJO = sps
        Dim SnippetBarOrientation1 As String = sbJO.RunMethod("getOrientation",Null)
         If SnippetBarOrientation1 = "VERTICAL" Then
            ssp.ScroolBar_Visible = sps.As(Node).Visible
            SplitPaneScrollBar = sbJO
        End If
    Next
   
    If SplitPaneScrollBar.IsInitialized And ssp.ScroolBar_Visible = True Then
        Dim position As Double
        Dim mSnippet As Int = modDBProject.ModuleNote
        ssp.MinValue = SplitPaneScrollBar.RunMethod("getMin", Null) 'ignore
        ssp.MaxValue = SplitPaneScrollBar.RunMethod("getMax", Null) 'ignore
       
        If mEditing = True Then
            If isFocused.taSourceCode Then
                position = ssp.taSourceCode(mSnippet)
            Else If isFocused.taNote Then
                position = ssp.taNote(mSnippet)
            End If
        Else
            position = ssp.BBCodeView(mSnippet)
        End If
       
        SplitPaneScrollBar.RunMethod("setValue", Array(position))
       
        Dim EventName As String = IIf(GlobalVariable = 1, "BBCodeView", IIf(GlobalVariable = 2, "SourceCode", "Note"))
   
        Dim ref As Reflector
        ref.Target = SplitPaneScrollBar
        ref.AddChangeListener(EventName&"_ScrollPosition","valueProperty")
    End If
End Sub

Private Sub BBCodeView_ScrollPosition_Changed(OldVal As Object,NewVal As Object)
    If mEditing = False Then
        ssp.BBCodeView(modDBProject.ModuleNote) = NewVal.As(Double)
    End If
End Sub

Private Sub SourceCode_ScrollPosition_Changed(OldVal As Object,NewVal As Object)
    If mEditing = True Then
        If isFocused.taSourceCode Then
            ssp.taSourceCode(modDBProject.ModuleNote) = NewVal.As(Double)
        Else If isFocused.taNote Then
            ssp.taNote(modDBProject.ModuleNote) = NewVal.As(Double)
        End If
    End If
End Sub

Private Sub Note_ScrollPosition_Changed(OldVal As Object,NewVal As Object)
    If mEditing = True Then
        If isFocused.taSourceCode Then
            ssp.taSourceCode(modDBProject.ModuleNote) = NewVal.As(Double)
        Else If isFocused.taNote Then
            ssp.taNote(modDBProject.ModuleNote) = NewVal.As(Double)
        End If
    End If
End Sub
 
Upvote 0
Solution
Top