IDE: source editor tabs: if no drag activate page

git-svn-id: trunk@22527 -
This commit is contained in:
mattias 2009-11-11 11:08:42 +00:00
parent 41c81e64f5
commit 314558a8f2

View File

@ -447,15 +447,18 @@ type
private
FMouseDownTabIndex: Integer;
FOnDragMoveTab: TDragMoveTabEvent;
FTabDragged: boolean;
protected
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X,
Y: Integer); override;
procedure DragOver(Source: TObject; X, Y: Integer; State: TDragState;
var Accept: Boolean); override;
property MouseDownTabIndex: Integer read FMouseDownTabIndex;
public
procedure DragDrop(Source: TObject; X, Y: Integer); override;
property OnDragMoveTab: TDragMoveTabEvent read FOnDragMoveTab write FOnDragMoveTab;
end;
end;
{ TSourceNotebook }
@ -7255,12 +7258,27 @@ end;
procedure TDragableNotebook.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
begin
FTabDragged:=false;
inherited MouseDown(Button, Shift, X, Y);
FMouseDownTabIndex := TabIndexAtClientPos(Point(X,Y));
if (Button = mbLeft) and (FMouseDownTabIndex >= 0) then
BeginDrag(False);
end;
procedure TDragableNotebook.MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
var
MouseUpTabIndex: LongInt;
begin
inherited MouseUp(Button, Shift, X, Y);
if not FTabDragged then begin
// no drag => check for normal click and activate page
MouseUpTabIndex := TabIndexAtClientPos(Point(X,Y));
if (Button = mbLeft) and (FMouseDownTabIndex = MouseUpTabIndex) then
PageIndex:=MouseUpTabIndex;
end;
end;
procedure TDragableNotebook.DragOver(Source: TObject; X, Y: Integer; State: TDragState;
var Accept: Boolean);
var
@ -7285,9 +7303,11 @@ begin
then begin
TabIndex := TabIndexAtClientPos(Point(X,Y));
if (TabIndex >= 0) and ( (Source <> self) or (TabIndex <> MouseDownTabIndex) )
then
then begin
FTabDragged:=true;
FOnDragMoveTab(Self, Source, TDragableNotebook(Source).MouseDownTabIndex,
TabIndex);
end;
end;
end;