mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 06:22:30 +02:00
IDE: improve drag-n-drop logic in Component Palette Options page. Accept only in right places.
git-svn-id: trunk@42914 -
This commit is contained in:
parent
b49550e81b
commit
041c0ccdaf
@ -355,7 +355,7 @@ var
|
|||||||
', ItemIndex=', lb.ItemIndex]);
|
', ItemIndex=', lb.ItemIndex]);
|
||||||
if lb.ItemIndex < DestInd then
|
if lb.ItemIndex < DestInd then
|
||||||
Dec(DestInd);
|
Dec(DestInd);
|
||||||
if (lb.ItemIndex > 0) and (DestInd > 0) and (lb.ItemIndex <> DestInd) then
|
if (lb.ItemIndex > 0) and (lb.ItemIndex <> DestInd) then
|
||||||
begin
|
begin
|
||||||
lb.Items.Move(lb.ItemIndex, DestInd);
|
lb.Items.Move(lb.ItemIndex, DestInd);
|
||||||
lb.ItemIndex := DestInd;
|
lb.ItemIndex := DestInd;
|
||||||
@ -382,7 +382,7 @@ var
|
|||||||
DestPage := lb.Items[DestInd];
|
DestPage := lb.Items[DestInd];
|
||||||
if SrcPage <> DestPage then
|
if SrcPage <> DestPage then
|
||||||
begin
|
begin
|
||||||
// Source
|
// Source component
|
||||||
Ind := lb.Items.IndexOf(SrcPage);
|
Ind := lb.Items.IndexOf(SrcPage);
|
||||||
Assert(Ind > -1, 'TCompPaletteOptionsFrame.PagesListBoxDragDrop: '
|
Assert(Ind > -1, 'TCompPaletteOptionsFrame.PagesListBoxDragDrop: '
|
||||||
+'source page index not found.');
|
+'source page index not found.');
|
||||||
@ -392,7 +392,7 @@ var
|
|||||||
+'source component index not found.');
|
+'source component index not found.');
|
||||||
xComp := SrcComps.Objects[Ind];
|
xComp := SrcComps.Objects[Ind];
|
||||||
SrcComps.Delete(Ind);
|
SrcComps.Delete(Ind);
|
||||||
// Destination
|
// Destination component
|
||||||
Ind := lb.Items.IndexOf(DestPage);
|
Ind := lb.Items.IndexOf(DestPage);
|
||||||
Assert(Ind > -1, 'TCompPaletteOptionsFrame.PagesListBoxDragDrop: '
|
Assert(Ind > -1, 'TCompPaletteOptionsFrame.PagesListBoxDragDrop: '
|
||||||
+'destination page index not found.');
|
+'destination page index not found.');
|
||||||
@ -414,10 +414,13 @@ var
|
|||||||
begin
|
begin
|
||||||
lb := Sender as TListBox;
|
lb := Sender as TListBox;
|
||||||
DestInd := lb.ItemAtPos(Point(X, Y), true);
|
DestInd := lb.ItemAtPos(Point(X, Y), true);
|
||||||
if Source is TListBox then
|
if DestInd > 0 then
|
||||||
DoInsideListBox
|
begin
|
||||||
else if Source is TListView then
|
if Source is TListBox then
|
||||||
DoFromListView(Source as TListView);
|
DoInsideListBox
|
||||||
|
else if Source is TListView then
|
||||||
|
DoFromListView(Source as TListView);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCompPaletteOptionsFrame.PagesListBoxDragOver(Sender,
|
procedure TCompPaletteOptionsFrame.PagesListBoxDragOver(Sender,
|
||||||
@ -430,9 +433,9 @@ begin
|
|||||||
lb := Sender as TListBox;
|
lb := Sender as TListBox;
|
||||||
DestPt := Point(X, Y);
|
DestPt := Point(X, Y);
|
||||||
DestInd := lb.ItemAtPos(DestPt, true);
|
DestInd := lb.ItemAtPos(DestPt, true);
|
||||||
Accept := ( (Source is TListBox) and (Source = Sender)
|
Accept := (DestInd > 0)
|
||||||
and (lb.ItemIndex > 0) and (DestInd > 0)
|
and ( ( (Source is TListBox) and (Source = Sender) and (lb.ItemIndex > 0)
|
||||||
) or (Source is TListView);
|
) or (Source is TListView) );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Drag-drop ComponentsListView
|
// Drag-drop ComponentsListView
|
||||||
@ -454,7 +457,7 @@ begin
|
|||||||
if (SrcItem.Index > -1) and (DestInd > -1) and (SrcItem.Index <> DestInd) then
|
if (SrcItem.Index > -1) and (DestInd > -1) and (SrcItem.Index <> DestInd) then
|
||||||
begin
|
begin
|
||||||
lv.Selected := Nil;
|
lv.Selected := Nil;
|
||||||
lv.items.Move(SrcItem.Index, DestInd);
|
lv.Items.Move(SrcItem.Index, DestInd);
|
||||||
lv.Selected := lv.Items[DestInd];
|
lv.Selected := lv.Items[DestInd];
|
||||||
UpdateCompMoveButtons(DestInd);
|
UpdateCompMoveButtons(DestInd);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user