diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2009-03-30 09:25:32 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2009-03-30 09:25:32 +0000 |
commit | 2078f282426af065666571575ffa4c233c42d947 (patch) | |
tree | 87fc678cef298854e77b5b851861bd1fe24369c1 | |
parent | c74a9d112f38ded37c8f76808bd8ad80e107a553 (diff) | |
download | fpGUI-2078f282426af065666571575ffa4c233c42d947.tar.xz |
* Patch fixing: Quick drag causes list order corruption.
-rw-r--r-- | src/gui/fpg_listbox.pas | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/gui/fpg_listbox.pas b/src/gui/fpg_listbox.pas index 8e9af727..56f53d0d 100644 --- a/src/gui/fpg_listbox.pas +++ b/src/gui/fpg_listbox.pas @@ -548,6 +548,7 @@ end; procedure TfpgBaseListBox.HandleMouseMove(x, y: integer; btnstate: word; shiftstate: TShiftState); var NewFocus: Integer; + i: Integer; begin inherited HandleMouseMove(x, y, btnstate, shiftstate); @@ -561,8 +562,17 @@ begin if NewFocus < 0 then NewFocus := 0; - if FDragToReorder and FMouseDragging and (NewFocus<ItemCount) then - Exchange(FocusItem, NewFocus); + if FDragToReorder and FMouseDragging then + begin + if NewFocus > ItemCount-1 then + NewFocus := ItemCount-1; + if FocusItem < NewFocus then + for i := FocusItem to NewFocus-1 do + Exchange(i, i+1) + else if FocusItem > NewFocus then + for i := FocusItem-1 downto NewFocus do + Exchange(i+1, i); + end; FocusItem := NewFocus; end; |