B4J Question Drag and Drop From a listview to delete causes jump to the top of the form

stevel05

Expert
Licensed User
Longtime User
I have had another look at this but i can't work out why clicking on delete after selecting an item behaves differently from dragging an item onto the delete node. It appears to be triggered by the Lv.Items.RemoveAt, which causes the scroll when dragged but not when clicked, although the scroll is not registered if a scroll listener is applied to the ListView.

I have also tried changing the Transfer mode to Copy, but it is no different.

If it were my project I would now try implementing dragging without using the library to see if it behaves in the same manner.
 
Last edited:
Upvote 0

Jorge M A

Well-Known Member
Licensed User
Longtime User
I have no idea what causes the effect you mention, but I managed to avoid it using your example project. Maybe it's an "workaround", but I think the behavior is the desired one, just requesting focus to target pane, in Drag Exit event.
B4X:
Sub MToMMoveT_DragExited(e As DragEvent)
    Log("MToMMoveT DragExited")
    Dim L As TextArea = e.GetEventSource
    L.Style = ";-fx-control-inner-background: rgba(95,158,160,.2);"
    
    L.RequestFocus
    
End Sub
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Excellent @Jorge M A , nice catch. Will have to think about why it works, but it seems to have done the trick :).
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I can only come up with the fact that as in the original, the focused view is removed, it forces a redraw of the whole ScrollView. Where as moving the focus to a view that isn't removed negates the need for a redraw. But can't really prove the theory.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Thinking about it further I think it's more likely that if the focused node is not removed then the scroll pane is scrolled to maintain it's position. If the focused node is removed, then it can't reposition itself.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
I have no idea what causes the effect you mention, but I managed to avoid it using your example project. Maybe it's an "workaround", but I think the behavior is the desired one, just requesting focus to target pane, in Drag Exit event.
B4X:
Sub MToMMoveT_DragExited(e As DragEvent)
    Log("MToMMoveT DragExited")
    Dim L As TextArea = e.GetEventSource
    L.Style = ";-fx-control-inner-background: rgba(95,158,160,.2);"
   
    L.RequestFocus
   
End Sub
Nice work Jorge M A! Thank you. Should have thought about that!
 
Upvote 0
Top