ideintf, designer: add MouseDown and MouseUp event handlers for designer

git-svn-id: trunk@51144 -
This commit is contained in:
ondrej 2016-01-03 12:06:07 +00:00
parent 3fb93ad0bf
commit cdfb590aee
2 changed files with 73 additions and 0 deletions

View File

@ -1244,6 +1244,8 @@ type
htGetAncestorInstProp,
htAddClicked, // user selected a component class and clicked on a form to add a component
htComponentRenamed,
htMouseDown,
htMouseUp,
// persistent selection
htBeforeAddPersistent,
htPersistentAdded,
@ -1332,6 +1334,10 @@ type
procedure Unselect(const APersistent: TPersistent);
function IsSelected(const APersistent: TPersistent): boolean;
procedure SelectOnlyThis(const APersistent: TPersistent);
procedure MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
// persistent objects
function GetObject(const aName: ShortString): TPersistent;
function GetObjectName(Instance: TPersistent): ShortString;
@ -1412,6 +1418,14 @@ type
const OnGetAncestorInstProp: TPropHookGetAncestorInstProp);
procedure RemoveHandlerGetAncestorInstProp(
const OnGetAncestorInstProp: TPropHookGetAncestorInstProp);
procedure AddHandlerMouseDown(
const OnMouseDown: TMouseEvent);
procedure RemoveHandlerMouseDown(
const OnMouseDown: TMouseEvent);
procedure AddHandlerMouseUp(
const OnMouseUp: TMouseEvent);
procedure RemoveHandlerMouseUp(
const OnMouseUp: TMouseEvent);
// component create, delete, rename
procedure AddHandlerComponentRenamed(
const OnComponentRenamed: TPropHookComponentRenamed);
@ -6108,6 +6122,34 @@ begin
end;
end;
procedure TPropertyEditorHook.MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
i: Integer;
Handler: TMouseEvent;
begin
i := GetHandlerCount(htMouseDown);
while GetNextHandlerIndex(htMouseDown, i) do
begin
Handler := TMouseEvent(FHandlers[htMouseDown][i]);
Handler(Sender, Button, Shift, X, Y);
end;
end;
procedure TPropertyEditorHook.MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
i: Integer;
Handler: TMouseEvent;
begin
i := GetHandlerCount(htMouseUp);
while GetNextHandlerIndex(htMouseUp, i) do
begin
Handler := TMouseEvent(FHandlers[htMouseUp][i]);
Handler(Sender, Button, Shift, X, Y);
end;
end;
procedure TPropertyEditorHook.Revert(Instance:TPersistent;
PropInfo:PPropInfo);
var
@ -6499,12 +6541,35 @@ begin
AddHandler(htModified,TMethod(OnModified));
end;
procedure TPropertyEditorHook.AddHandlerMouseDown(const OnMouseDown: TMouseEvent
);
begin
AddHandler(htMouseDown,TMethod(OnMouseDown));
end;
procedure TPropertyEditorHook.AddHandlerMouseUp(const OnMouseUp: TMouseEvent);
begin
AddHandler(htMouseUp,TMethod(OnMouseUp));
end;
procedure TPropertyEditorHook.RemoveHandlerModified(
const OnModified: TPropHookModified);
begin
RemoveHandler(htModified,TMethod(OnModified));
end;
procedure TPropertyEditorHook.RemoveHandlerMouseDown(
const OnMouseDown: TMouseEvent);
begin
RemoveHandler(htMouseDown,TMethod(OnMouseDown));
end;
procedure TPropertyEditorHook.RemoveHandlerMouseUp(const OnMouseUp: TMouseEvent
);
begin
RemoveHandler(htMouseUp,TMethod(OnMouseUp));
end;
procedure TPropertyEditorHook.AddHandlerRevert(const OnRevert: TPropHookRevert);
begin
AddHandler(htRevert,TMethod(OnRevert));

View File

@ -2142,8 +2142,12 @@ begin
ControlSelection.AssignPersistent(MouseDownComponent);
end;
if PropertyEditorHook<>nil then
PropertyEditorHook.MouseDown(Sender, Button, Shift, p.X, p.Y);
if not ControlSelection.OnlyVisualComponentsSelected and ShowComponentCaptions then
Form.Invalidate;
{$IFDEF VerboseDesigner}
DebugLn('[TDesigner.MouseDownOnControl] END');
{$ENDIF}
@ -2527,6 +2531,10 @@ begin
Exclude(FFlags,dfHasSized);
MouseDownComponent:=nil;
MouseDownSender:=nil;
if PropertyEditorHook<>nil then
PropertyEditorHook.MouseUp(Sender, Button, Shift, p.X, p.Y);
{$IFDEF VerboseDesigner}
DebugLn('[TDesigner.MouseUpOnControl] END');
{$ENDIF}