TreeView: Fix selection and scrolling behaviour when ShowCheck property is set.
[GB.GUI.BASE] * BUG: TreeView: Fix selection and scrolling behaviour when ShowCheck property is set.
This commit is contained in:
parent
6a8055ccc4
commit
ff5ec08817
5 changed files with 69 additions and 49 deletions
|
@ -7,7 +7,7 @@ Component=gb.image
|
||||||
Component=gb.gui
|
Component=gb.gui
|
||||||
Arguments=[["-style=oxygen"],["-style=qtcurve"]]
|
Arguments=[["-style=oxygen"],["-style=qtcurve"]]
|
||||||
CurrentArgument=0
|
CurrentArgument=0
|
||||||
Environment="GB_JIT_DEBUG=1\nGB_GUI=gb.gtk3\nLIBOVERLAY_SCROLLBAR=0"
|
Environment="GB_JIT_DEBUG=1\nGB_GUI=gb.qt5\nLIBOVERLAY_SCROLLBAR=0"
|
||||||
TabSize=2
|
TabSize=2
|
||||||
Language=fr
|
Language=fr
|
||||||
Type=Component
|
Type=Component
|
||||||
|
|
|
@ -62,6 +62,7 @@ Event Draw(X As Integer, Y As Integer, Width As Integer, Height As Integer, Row
|
||||||
|
|
||||||
Public _DoNotDrawSelection As Boolean
|
Public _DoNotDrawSelection As Boolean
|
||||||
Public _NoMouse As Boolean
|
Public _NoMouse As Boolean
|
||||||
|
Public _ToggleSelection As Boolean
|
||||||
|
|
||||||
Private $hView As ScrollArea
|
Private $hView As ScrollArea
|
||||||
Private $bGrid As Boolean = True
|
Private $bGrid As Boolean = True
|
||||||
|
@ -956,6 +957,19 @@ Private Sub InRowHeader(X As Integer) As Boolean
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
Private Sub StartScrollTimer()
|
||||||
|
|
||||||
|
Dim F As Integer = _GetFrameWidth()
|
||||||
|
|
||||||
|
$SX = Mouse.X - F
|
||||||
|
$SY = Mouse.Y - F
|
||||||
|
|
||||||
|
If $hTimerScroll Then Return
|
||||||
|
|
||||||
|
$hTimerScroll = New Timer(50) As "TimerScroll"
|
||||||
|
|
||||||
|
End
|
||||||
|
|
||||||
|
|
||||||
Public Sub ScrollArea_MouseMove()
|
Public Sub ScrollArea_MouseMove()
|
||||||
|
|
||||||
|
@ -972,11 +986,7 @@ Public Sub ScrollArea_MouseMove()
|
||||||
|
|
||||||
If $hRows.Count = 0 And If $hColumns.Count = 0 Then Return
|
If $hRows.Count = 0 And If $hColumns.Count = 0 Then Return
|
||||||
|
|
||||||
If $bInCell And If Mouse.Left And If Not $hTimerScroll Then
|
If $bInCell And If Mouse.Left Then StartScrollTimer
|
||||||
$hTimerScroll = New Timer As "TimerScroll"
|
|
||||||
$hTimerScroll.Delay = 50
|
|
||||||
$hTimerScroll.Start
|
|
||||||
Endif
|
|
||||||
|
|
||||||
MX = Mouse.X - F
|
MX = Mouse.X - F
|
||||||
MY = Mouse.Y - F
|
MY = Mouse.Y - F
|
||||||
|
@ -1092,8 +1102,6 @@ Public Sub ScrollArea_MouseMove()
|
||||||
|
|
||||||
X = MX
|
X = MX
|
||||||
Y = MY
|
Y = MY
|
||||||
$SX = X
|
|
||||||
$SY = Y
|
|
||||||
|
|
||||||
If Not System.RightToLeft Then X -= $hRows.W
|
If Not System.RightToLeft Then X -= $hRows.W
|
||||||
|
|
||||||
|
@ -1171,7 +1179,6 @@ Public Sub _EnsureVisibleScroll(X As Integer, Y As Integer)
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
|
||||||
Public Sub ScrollArea_MouseDrag()
|
Public Sub ScrollArea_MouseDrag()
|
||||||
|
|
||||||
If Me.Design Then Return
|
If Me.Design Then Return
|
||||||
|
@ -1179,16 +1186,12 @@ Public Sub ScrollArea_MouseDrag()
|
||||||
If _NoMouse Then Return
|
If _NoMouse Then Return
|
||||||
|
|
||||||
$bIgnoreMove = False
|
$bIgnoreMove = False
|
||||||
If $bResize Or If $bMoveSelect Then
|
If $bResize Or If $bMoveSelect Or If $bMoveUnselect Then
|
||||||
Stop Event
|
Stop Event
|
||||||
Return
|
Return
|
||||||
Endif
|
Endif
|
||||||
|
|
||||||
If Not $hTimerScroll Then
|
StartScrollTimer
|
||||||
$hTimerScroll = New Timer As "TimerScroll"
|
|
||||||
$hTimerScroll.Delay = 50
|
|
||||||
$hTimerScroll.Start
|
|
||||||
Endif
|
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
@ -1243,12 +1246,17 @@ Public Sub ScrollArea_MouseDown()
|
||||||
Dec $iRow
|
Dec $iRow
|
||||||
MoveTo($iRow + 1, -1)
|
MoveTo($iRow + 1, -1)
|
||||||
Else If Not _IsRowSelected($iRow) Then
|
Else If Not _IsRowSelected($iRow) Then
|
||||||
$hRows._GetSel().UnSelectAll
|
If Not _ToggleSelection Then $hRows._GetSel().UnSelectAll
|
||||||
$hRows.Select($iRow, 1)
|
$hRows.Select($iRow, 1)
|
||||||
$iMoveSelectRow = $iRow
|
$iMoveSelectRow = $iRow
|
||||||
$hMoveOldSelection = $hRows._SaveSelection()
|
$hMoveOldSelection = $hRows._SaveSelection()
|
||||||
$bMoveSelect = True
|
$bMoveSelect = True
|
||||||
Else
|
Else
|
||||||
|
If _ToggleSelection Then
|
||||||
|
$hRows.UnSelect($iRow, 1)
|
||||||
|
$hMoveOldSelection = $hRows._SaveSelection()
|
||||||
|
$bMoveUnSelect = True
|
||||||
|
Endif
|
||||||
$iMoveSelectRow = $iRow
|
$iMoveSelectRow = $iRow
|
||||||
Endif
|
Endif
|
||||||
Endif
|
Endif
|
||||||
|
@ -1297,6 +1305,12 @@ End
|
||||||
Private Sub AfterMouseUp()
|
Private Sub AfterMouseUp()
|
||||||
|
|
||||||
If Me.Design Then Return
|
If Me.Design Then Return
|
||||||
|
|
||||||
|
If $hTimerScroll Then
|
||||||
|
$hTimerScroll.Stop
|
||||||
|
$hTimerScroll = Null
|
||||||
|
Endif
|
||||||
|
|
||||||
If _NoMouse Then Return
|
If _NoMouse Then Return
|
||||||
|
|
||||||
$bResize = False
|
$bResize = False
|
||||||
|
@ -1306,11 +1320,6 @@ Private Sub AfterMouseUp()
|
||||||
$iMoveSelectRow = -1
|
$iMoveSelectRow = -1
|
||||||
$bIgnoreMove = False
|
$bIgnoreMove = False
|
||||||
|
|
||||||
If $hTimerScroll Then
|
|
||||||
$hTimerScroll.Stop
|
|
||||||
$hTimerScroll = Null
|
|
||||||
Endif
|
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
|
||||||
|
@ -1444,7 +1453,7 @@ Public Sub MoveTo(Row As Integer, Column As Integer)
|
||||||
Raise Change
|
Raise Change
|
||||||
If $iMode = Select.Single Then
|
If $iMode = Select.Single Then
|
||||||
Raise Select
|
Raise Select
|
||||||
Else If $bMoveSelect Or $bMoveUnSelect Then
|
Else If $bMoveSelect Or If $bMoveUnSelect Then
|
||||||
If $hMoveOldSelection Then
|
If $hMoveOldSelection Then
|
||||||
$hRows._RestoreSelection($hMoveOldSelection)
|
$hRows._RestoreSelection($hMoveOldSelection)
|
||||||
S = Min($iRow, $iMoveSelectRow)
|
S = Min($iRow, $iMoveSelectRow)
|
||||||
|
|
|
@ -86,6 +86,7 @@ End
|
||||||
Public Sub tvwTest_MouseDrag()
|
Public Sub tvwTest_MouseDrag()
|
||||||
|
|
||||||
Debug "START"
|
Debug "START"
|
||||||
|
Drag.Icon = Picture["icon:/small/text"]
|
||||||
Drag(tvwTest, "toto", "text/plain")
|
Drag(tvwTest, "toto", "text/plain")
|
||||||
Debug "END"
|
Debug "END"
|
||||||
|
|
||||||
|
|
|
@ -57,12 +57,14 @@
|
||||||
MoveScaled(13,22,42,26)
|
MoveScaled(13,22,42,26)
|
||||||
Drop = True
|
Drop = True
|
||||||
Expand = True
|
Expand = True
|
||||||
|
Mode = Select.Multiple
|
||||||
Sorted = True
|
Sorted = True
|
||||||
Editable = True
|
Editable = True
|
||||||
Header = False
|
Header = False
|
||||||
Resizable = True
|
Resizable = True
|
||||||
Border = False
|
Border = False
|
||||||
ShowLines = True
|
ShowLines = True
|
||||||
|
ShowCheck = True
|
||||||
}
|
}
|
||||||
{ GridView1 GridView
|
{ GridView1 GridView
|
||||||
MoveScaled(20,51,37,27)
|
MoveScaled(20,51,37,27)
|
||||||
|
|
|
@ -751,8 +751,6 @@ Public Sub GridView_MouseDown()
|
||||||
Dim iRow As Integer = $hView.RowAt(Mouse.Y)
|
Dim iRow As Integer = $hView.RowAt(Mouse.Y)
|
||||||
Dim hItem As _TreeView_Item = RowToItem(iRow)
|
Dim hItem As _TreeView_Item = RowToItem(iRow)
|
||||||
Dim X As Integer
|
Dim X As Integer
|
||||||
Dim iFrom As Integer
|
|
||||||
Dim bSelect As Boolean
|
|
||||||
|
|
||||||
If Not hItem Then Return
|
If Not hItem Then Return
|
||||||
If Mouse.Click > 1 Then Return
|
If Mouse.Click > 1 Then Return
|
||||||
|
@ -782,30 +780,39 @@ Public Sub GridView_MouseDown()
|
||||||
|
|
||||||
Endif
|
Endif
|
||||||
|
|
||||||
If $bShowCheck Then
|
' If False Then
|
||||||
|
'
|
||||||
If System.RightToLeft Then
|
' If System.RightToLeft Then
|
||||||
X -= $iDepthW
|
' X -= $iDepthW
|
||||||
Else
|
' Else
|
||||||
X += $iDepthW
|
' X += $iDepthW
|
||||||
Endif
|
' Endif
|
||||||
|
'
|
||||||
If Mouse.X >= X + $iDepthW \ 8 Then 'And If Mouse.X < X + $iDepthW - $iDepthW \ 8 Then
|
' If Mouse.X >= X + $iDepthW \ 8 Then 'And If Mouse.X < X + $iDepthW - $iDepthW \ 8 Then
|
||||||
iFrom = $hView.Row
|
'
|
||||||
If Mouse.Shift And If iFrom >= 0 Then
|
' iFrom = $hView.Row
|
||||||
bSelect = RowToItem(iFrom).Selected
|
' If Mouse.Shift And If iFrom >= 0 Then
|
||||||
While iFrom <> iRow
|
' $bSelectItem = RowToItem(iFrom).Selected
|
||||||
iFrom += Sgn(iRow - iFrom)
|
' While iFrom <> iRow
|
||||||
RowToItem(iFrom).Selected = bSelect
|
' iFrom += Sgn(iRow - iFrom)
|
||||||
Wend
|
' RowToItem(iFrom).Selected = $bSelectItem
|
||||||
Else
|
' Wend
|
||||||
hItem.Selected = Not hItem.Selected
|
' $hView.Row = iRow
|
||||||
Endif
|
' Else
|
||||||
Endif
|
' $hView.Row = iRow
|
||||||
|
' hItem.Selected = Not hItem.Selected
|
||||||
$hView.Row = iRow
|
' $bSelectItem = hItem.Selected
|
||||||
|
' Endif
|
||||||
Endif
|
'
|
||||||
|
' Stop Event
|
||||||
|
'
|
||||||
|
' Else
|
||||||
|
'
|
||||||
|
' $hView.Row = iRow
|
||||||
|
'
|
||||||
|
' Endif
|
||||||
|
'
|
||||||
|
' Endif
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
@ -1799,7 +1806,8 @@ Private Sub ShowCheck_Write(Value As Boolean)
|
||||||
If $bShowCheck = Value Then Return
|
If $bShowCheck = Value Then Return
|
||||||
$bShowCheck = Value
|
$bShowCheck = Value
|
||||||
$hView._DoNotDrawSelection = Value
|
$hView._DoNotDrawSelection = Value
|
||||||
$hView._NoMouse = Value
|
$hView._ToggleSelection = Value
|
||||||
|
'$hView._NoMouse = Value
|
||||||
$hView.Refresh
|
$hView.Refresh
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
Loading…
Reference in a new issue