📄 childrenctrl.pas
字号:
unit ChildrenCtrl;
interface
uses
SysUtils, stdctrls, forms, buttons, classes, controls, patterns,
ChildrenMdl, ChildrenView;
type
TControllerChildren = class(TController)
model: TModelChildren;
view: TViewChildren;
protected
procedure DoCommand(ACommand: string; const args: TObject = nil); override;
procedure DoCommand(ACommand: string; const args: string = ''); override;
public
constructor Create;
destructor Destroy; override;
procedure OnClick(Sender: TObject); //for ieventListener
procedure OnMouseEvent(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
end;
implementation
uses commandlist;
procedure TControllerChildren.OnClick(Sender: TObject);
begin
if Sender is TButton then
begin
self.SendCommand(View.getCommand);
//notify the tree index
self.SendCommand(CMD_NODE_SELECT, 'Children');
end;
end;
procedure TControllerChildren.OnMouseEvent(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
end;
constructor TControllerChildren.Create;
begin
inherited;
model := TModelChildren.Create;
view := TViewChildren.create(nil);
view.setEventHandler(self.onClick);
model.RegObserver(view);
end;
destructor TControllerChildren.destroy;
begin
freeAndNil(model);
freeAndNil(view);
inherited;
end;
procedure TControllerChildren.DoCommand(ACommand: string; const args: string = '');
begin
if (ACommand = CMD_ALL_STOP_DRAWING) or
(ACommand = CMD_MOM_NEWCLOTHES) or
(ACommand = CMD_MOM_LOVEME) or
(ACommand = CMD_DAD_PLAYGAME) or
(ACommand = CMD_CLEAR_SELECTION) then
begin
model.response(ACommand, nil, args);
end;
end;
procedure TControllerChildren.DoCommand(ACommand: string; const args: TObject = nil);
begin
if ACommand = CMD_REQUIRE_CHILDRENVIEW then
self.SendCommand(CMD_SHOW_CHILDRENVIEW, view)
else if (ACommand = CMD_NODE_SELECT) and
(args <> nil) and
(uppercase(TCommand(args).getCommandTxt) = uppercase('Children')) then
begin
model.response(ACommand, args as TCommand);
end;
end;
initialization
ControlCenter.RegController(TControllerChildren.Create);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -