B4J Question TableView - simulate STRG - multiselect without ctrl

Discussion in 'B4J Questions' started by Patent, May 9, 2017.

  1. Patent

    Patent Member Licensed User

    Dear Community,

    is it possible to "simulate" the STRG Key press while selecting Rows in a tableview,
    so to select different and many rows by mouseclick (without pressing STRG)?

  2. Erel

    Erel Administrator Staff Member Licensed User

    What do you mean with STRG? How you are selecting multiple rows?
  3. Patent

    Patent Member Licensed User

    by pressing STRG on the Keyboard. and this works fine in b4j.
    i want to do this without keyboard,for instance by setting a toggle button.

    big sorry: have forgotten that most of you are using a internat. keyboard. its the CTRL button on yours........
    KitCarlson likes this.
  4. Enrique Gonzalez R

    Enrique Gonzalez R Well-Known Member Licensed User

    Patent likes this.
  5. Erel

    Erel Administrator Staff Member Licensed User

    I guess that I'm missing something, however with the attached project I cannot select multiple rows.

    Attached Files:

  6. Patent

    Patent Member Licensed User

    this works with full "windows like" behavior (CTRL a(ll), Shift, CTRL)....

    Attached Files:

  7. Erel

    Erel Administrator Staff Member Licensed User

    Would have saved 5 posts if you wrote that you are changing the selection mode with JavaObject.

    You can use this code to handle the pressed event before it reaches the default handler and manage the selection yourself:
    Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private TableView1 As TableView
    Private selectedRows As List
    Private tvSelModel As JavaObject
    End Sub

    Sub AppStart (Form1 As Form, Args() As String)
       MainForm = Form1
    "1"'Load the layout file.
       MainForm.Title = 
    "Table Example with CTRL Function"
    Array As String("Col1""Col2"))
    For i = 1 To 100
    Array(i, i))
    Dim jotable As JavaObject=TableView1

    'Get the Selection Mode Enum:
       Dim joSelMode As JavaObject
    'get Selection Model:
       tvSelModel = jotable.RunMethodJO("getSelectionModel"Null)
    'set the selectionmode of the tableview by using the enum
    Dim r As Reflector
       r.Target = TableView1
    End Sub

    Sub TableView1_Filter (EventData As Event)
    Dim jo As JavaObject = EventData
    Dim targetType As String = GetType(jo.RunMethod("getTarget"Null))
    If targetType = "javafx.scene.control.TableColumn$1$1" Then
    Dim row As JavaObject = jo.RunMethodJO("getTarget"Null).RunMethod("getTableRow"Null)
    Dim index As Int = row.RunMethod("getIndex"Null)
    Dim i As Int = selectedRows.IndexOf(index)
    If i > -1 Then
    Dim indices(selectedRows.Size - 1As Int
    For i = 0 To indices.Length - 1
             indices(i) = selectedRows.Get(i + 
    "selectIndices"Array(selectedRows.Get(0), indices))
    End If
    Else if targetType = "javafx.scene.control.TableRow" Then
    End If
    End Sub
    Patent likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice