Designer: Update Enable state of buttons in Tab Order dialog while user navigates it

git-svn-id: trunk@30350 -
This commit is contained in:
juha 2011-04-17 14:55:06 +00:00
parent 1977485b9c
commit 71961a04c9
2 changed files with 20 additions and 0 deletions

View File

@ -50,6 +50,7 @@ object TabOrderDialog: TTabOrderDialog
ReadOnly = True
RightClickSelect = True
TabOrder = 0
OnClick = ItemTreeviewClick
Options = [tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips]
end
end

View File

@ -44,12 +44,14 @@ type
ArrowUp: TSpeedButton;
ItemTreeview: TTreeView;
procedure FormShow(Sender: TObject);
procedure ItemTreeviewClick(Sender: TObject);
procedure TabOrderDialogCREATE(Sender: TObject);
procedure UpSpeedbuttonCLICK(Sender: TObject);
procedure DownSpeedbuttonCLICK(Sender: TObject);
private
FUpdating: Boolean;
function SwapNodes(ANode1, ANode2: TTreeNode): boolean;
procedure CheckButtonsEnabled;
procedure CreateNodes(ParentControl: TWinControl; ParentNode: TTreeNode);
procedure Refresh(Force: boolean);
procedure OnSomethingChanged;
@ -94,6 +96,11 @@ begin
Refresh(true);
end;
procedure TTabOrderDialog.ItemTreeviewClick(Sender: TObject);
begin
CheckButtonsEnabled;
end;
procedure TTabOrderDialog.UpSpeedbuttonCLICK(Sender: TObject);
var
CurItem, NewItem: TTreeNode;
@ -103,6 +110,7 @@ begin
NewItem := CurItem.GetPrevSibling;
SwapNodes(NewItem, CurItem);
ItemTreeview.Selected:=CurItem;
CheckButtonsEnabled;
end;
procedure TTabOrderDialog.DownSpeedbuttonCLICK(Sender: TObject);
@ -114,6 +122,7 @@ begin
NewItem := CurItem.GetNextSibling;
SwapNodes(CurItem, NewItem);
ItemTreeview.Selected:=CurItem;
CheckButtonsEnabled;
end;
function TTabOrderDialog.SwapNodes(ANode1, ANode2: TTreeNode): boolean;
@ -131,6 +140,15 @@ begin
ANode2.Text := Ctrl2.Name + ' (' + IntToStr(Ctrl2.TabOrder) + ')';
end;
procedure TTabOrderDialog.CheckButtonsEnabled;
var
CurItem: TTreeNode;
begin
CurItem:=ItemTreeview.Selected;
ArrowUp.Enabled := Assigned(CurItem) and Assigned(CurItem.GetPrevSibling);
ArrowDown.Enabled := Assigned(CurItem) and Assigned(CurItem.GetNextSibling);
end;
procedure TTabOrderDialog.CreateNodes(ParentControl: TWinControl; ParentNode: TTreeNode);
var
AControl: TControl;
@ -184,6 +202,7 @@ begin
if Assigned(LookupRoot) and (LookupRoot is TWinControl) then begin
CreateNodes(TWinControl(LookupRoot), nil);
Caption:=Format(lisTabOrderOf, [TWinControl(LookupRoot).Name]);
CheckButtonsEnabled;
end;
finally
ItemTreeview.EndUpdate;