B4J Question B4XTableSelections : Select by CTRL+A and Shift+Click

MarcRB

Active Member
Licensed User
Longtime User
Hello,

How to use multiple lines selection in B4XTableSelections (mode = XSelections.MODE_MULTIPLE_LINES)
By pressing CTRL+A (Select all rows)
or Shift+Click Select all rows including and between the selected row and the last clicked row.

Best regard,
Marc
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Add a MenuBar and set the Menu Items field to:
[

{Text: "_Edit", Children:[
{Text: "Select _All", Tag: "SelectAll", Shortcut: {Key: "A", Modifier: "CONTROL"}}
] }

]

Add this code:
B4X:
Private Sub MenuBar1_Action
    Dim tag As String = Sender.As(MenuItem).Tag
    If tag = "SelectAll" Then
        SelectAll
    End If
End Sub

Private Sub SelectAll
    For Each rowid As Long In B4XTable1.VisibleRowIds
        If rowid > 0 Then
            XSelections.SelectedLines.Put(rowid, "")
        End If
    Next
    XSelections.Refresh
End Sub
 
Upvote 0

MarcRB

Active Member
Licensed User
Longtime User
Thanks Erel for CTRL+A suggestion.
If you have I nice way for shift +_mouseclick, I look forward to read it.


Underneath, I will try the shift + click selection as follow:
First storing the start-rowid in a var, at row click without shift pressed.
After keyboard shift + mouse click storing the end-rowid.
At that point I do have a start and end in a range of rowids / lines
In a for-next I can select each row in that range.
Most difficult will be detect the shift+mouseclick.

Maybe this post will be helpfull for me.
https://www.b4x.com/android/forum/threads/b4xtable-keyboard-navigation.135625/

If I have any good results , I will post it here.
 
Upvote 0
Top