View Issue Details

IDProjectCategoryView StatusLast Update
0006402JEDI VCL00 JVCL Componentspublic2020-05-19 09:55
ReporterarhahaAssigned Toobones 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionsuspended 
Product VersionDaily / GIT 
Target VersionFixed in Version 
Summary0006402: TJvCustomItemViewer can't implement multi items drag
Descriptionif you want implement multiple items drag, so firstly you select some items, the first, the second and the third item has been selected in sequence, then use mouse to click the second item and start to drag, code like below:

procedure TMyJvOwnerDrawViewer.MouseDown(Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  ItemInx: Integer;
begin
  inherited MouseDown(Button, Shift, X, Y);

  if Button = mbLeft then begin
    ItemInx := Self.ItemAtPos(X, Y, True);
    if (ItemInx >= 0) and (ItemInx < Self.Count) then begin
      if cdsSelected in Items[ItemInx].State then begin
        Self.BeginDrag(False, 10);
      end;
    end;
  end;
end;

Then you will find that the third item will be unselected! To fix this bug, we need add some code in unit JvCustomItemViewer.pas like this:

procedure TJvCustomItemViewer.SetSelectedIndex(const Value: Integer);
begin
  // if (FSelectedIndex <> Value) then
  begin
    if (FSelectedIndex >= 0) and (FSelectedIndex < Count) and (cdsSelected in Items[FSelectedIndex].State)
      and not Options.MultiSelect { <--- Support multiple item drag, Added By DSLIN, 2015-04-17 } then
      Items[FSelectedIndex].State := Items[FSelectedIndex].State - [cdsSelected];

    FSelectedIndex := Value;

    if (Value >= 0) and (Value < Count) and not (cdsSelected in Items[Value].State) then
      Items[Value].State := Items[Value].State + [cdsSelected];
  end;
end;

TagsNo tags attached.

Activities

obones

2015-09-14 11:23

administrator   ~0021189

Please provide the zipped sources of a sample application showing this

obones

2020-05-19 09:55

administrator   ~0021891

No reply in a timely manner, suspending the issue

Issue History

Date Modified Username Field Change
2015-04-17 05:04 arhaha New Issue
2015-09-14 11:23 obones Note Added: 0021189
2015-09-14 11:23 obones Status new => feedback
2020-05-19 09:55 obones Assigned To => obones
2020-05-19 09:55 obones Status feedback => resolved
2020-05-19 09:55 obones Resolution open => suspended
2020-05-19 09:55 obones Note Added: 0021891