Skip to content

Commit

Permalink
* Fixed issue #54: Add, Delete, Up and Down commands are enabled when…
Browse files Browse the repository at this point in the history
… no file is loaded

* Corrected sighature of TUpDown.OnChangingEx event handlers
  • Loading branch information
Joachim Marder committed Sep 21, 2017
1 parent 85d48ed commit 57c1ba5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
17 changes: 4 additions & 13 deletions Designer/FCommands.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ object FrameCommands: TFrameCommands
Top = 0
Height = 304
ResizeStyle = rsUpdate
ExplicitLeft = 210
ExplicitTop = 1
ExplicitHeight = 414
end
object PanelCommands: TPanel
Left = 0
Expand Down Expand Up @@ -116,7 +113,6 @@ object FrameCommands: TFrameCommands
ParentFont = False
Transparent = False
Layout = tlCenter
ExplicitWidth = 757
end
object PanelProps: TPanel
Left = 0
Expand Down Expand Up @@ -586,9 +582,6 @@ object FrameCommands: TFrameCommands
ParentFont = False
Transparent = False
Layout = tlCenter
ExplicitLeft = 1
ExplicitTop = 1
ExplicitWidth = 286
end
end
object PanelLargeImages: TPanel
Expand Down Expand Up @@ -617,8 +610,6 @@ object FrameCommands: TFrameCommands
ParentFont = False
Transparent = False
Layout = tlCenter
ExplicitTop = -6
ExplicitWidth = 469
end
end
end
Expand Down Expand Up @@ -657,8 +648,6 @@ object FrameCommands: TFrameCommands
ParentFont = False
Transparent = False
Layout = tlCenter
ExplicitLeft = 6
ExplicitTop = -6
end
end
object PanelLargeHCImages: TPanel
Expand Down Expand Up @@ -687,8 +676,6 @@ object FrameCommands: TFrameCommands
ParentFont = False
Transparent = False
Layout = tlCenter
ExplicitTop = -6
ExplicitWidth = 469
end
end
end
Expand Down Expand Up @@ -980,27 +967,31 @@ object FrameCommands: TFrameCommands
ImageIndex = 0
ShortCut = 24621
OnExecute = ActionAddCommandExecute
OnUpdate = ActionAddCommandUpdate
end
object ActionDeleteCommand: TAction
Category = 'Commands'
Caption = 'Delete'
Hint = 'Deletes the selected command'
ImageIndex = 1
OnExecute = ActionDeleteCommandExecute
OnUpdate = ActionUpdate
end
object ActionMoveUp: TAction
Category = 'Commands'
Caption = 'Up'
Hint = 'Moves the selected command up in the list'
ImageIndex = 2
OnExecute = ActionMoveUpExecute
OnUpdate = ActionUpdate
end
object ActionMoveDown: TAction
Category = 'Commands'
Caption = 'Down'
Hint = 'Moves the selected command down in the list'
ImageIndex = 3
OnExecute = ActionMoveDownExecute
OnUpdate = ActionUpdate
end
end
object PopupMenuList: TPopupMenu
Expand Down
16 changes: 14 additions & 2 deletions Designer/FCommands.pas
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ TFrameCommands = class(TFrame)
procedure EditDescriptionIdChange(Sender: TObject);
procedure EditDescriptionSymbolChange(Sender: TObject);
procedure UpDownChangingEx(Sender: TObject; var AllowChange: Boolean;
NewValue: SmallInt; Direction: TUpDownDirection);
NewValue: Integer; Direction: TUpDownDirection);
procedure EditTooltipTitleChange(Sender: TObject);
procedure EditTooltipTitleIdChange(Sender: TObject);
procedure EditTooltipTitleSymbolChange(Sender: TObject);
Expand All @@ -135,6 +135,8 @@ TFrameCommands = class(TFrame)
procedure ActionMoveUpExecute(Sender: TObject);
procedure ActionMoveDownExecute(Sender: TObject);
procedure BtnGenerateIDClick(Sender: TObject);
procedure ActionUpdate(Sender: TObject);
procedure ActionAddCommandUpdate(Sender: TObject);
private
{ Private declarations }
FDocument: TRibbonDocument;
Expand Down Expand Up @@ -188,6 +190,16 @@ procedure TFrameCommands.ActionAddCommandExecute(Sender: TObject);
Modified;
end;

procedure TFrameCommands.ActionUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled := Assigned(ListViewCommands.Selected);
end;

procedure TFrameCommands.ActionAddCommandUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled := Assigned(FDocument);
end;

procedure TFrameCommands.ActionDeleteCommandExecute(Sender: TObject);
begin
if Assigned(FCommand) and ((FCommand.ReferenceCount = 0) or
Expand Down Expand Up @@ -645,7 +657,7 @@ procedure TFrameCommands.ShowSelection;
end;

procedure TFrameCommands.UpDownChangingEx(Sender: TObject;
var AllowChange: Boolean; NewValue: SmallInt; Direction: TUpDownDirection);
var AllowChange: Boolean; NewValue: Integer; Direction: TUpDownDirection);
var
UpDown: TUpDown;
begin
Expand Down
5 changes: 5 additions & 0 deletions Designer/FViews.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -1564,22 +1564,27 @@ object FrameViews: TFrameViews
Caption = 'Add'
Hint = 'Adds a subitem to the selected node'
ImageIndex = 36
OnExecute = ActionAddButtonExecute
OnUpdate = TreeActionUpdate
end
object ActionDelete: TAction
Caption = 'Delete'
Hint = 'Deletes the selected item'
ImageIndex = 37
OnExecute = ActionDeleteExecute
OnUpdate = TreeActionUpdate
end
object ActionMoveUp: TAction
Caption = 'Up'
ImageIndex = 38
OnExecute = ActionMoveUpExecute
OnUpdate = TreeActionUpdate
end
object ActionMoveDown: TAction
Caption = 'Down'
ImageIndex = 39
OnExecute = ActionMoveDownExecute
OnUpdate = TreeActionUpdate
end
object ActionAddButton: TAction
Caption = 'Add Button'
Expand Down
6 changes: 6 additions & 0 deletions Designer/FViews.pas
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ TFrameViews = class(TFrame)
procedure ActionAddFloatieFontControlExecute(Sender: TObject);
procedure ActionMoveUpExecute(Sender: TObject);
procedure ActionMoveDownExecute(Sender: TObject);
procedure TreeActionUpdate(Sender: TObject);
private
{ Private declarations }
FDocument: TRibbonDocument;
Expand Down Expand Up @@ -1557,6 +1558,11 @@ procedure TFrameViews.ActionMoveUpExecute(Sender: TObject);
MoveNode(-1);
end;

procedure TFrameViews.TreeActionUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled := Assigned(TreeViewRibbon.Selected);
end;

procedure TFrameViews.Activate;
var
Command: TRibbonCommand;
Expand Down

0 comments on commit 57c1ba5

Please sign in to comment.