SynEdit, Mouse Actions: Fix issue with conflicting partially loaded mouse actions (load from resources)

Better handling in designer

git-svn-id: trunk@20527 -
This commit is contained in:
martin 2009-06-08 20:48:22 +00:00
parent 6de1371b98
commit b81b57c1e4
2 changed files with 35 additions and 3 deletions

View File

@ -35,7 +35,7 @@ unit SynEditMouseCmds;
interface
uses
Classes, Controls, SysUtils, SynEditStrConst, SynEditPointClasses;
Classes, Controls, SysUtils, SynEditStrConst, SynEditPointClasses, Dialogs;
const
// EditorMouseCommands
@ -150,6 +150,7 @@ type
procedure SetItem(Index: Integer; const AValue: TSynEditMouseAction);
protected
function GetOwner: TPersistent; override;
procedure Update(Item: TCollectionItem); override;
public
constructor Create(AOwner: TPersistent);
function Add: TSynEditMouseAction;
@ -383,6 +384,37 @@ begin
Result := FOwner;
end;
procedure TSynEditMouseActions.Update(Item: TCollectionItem);
var
i: Integer;
Err : ESynMouseCmdError;
begin
inherited Update(Item);
i := Count - 1;
Err := nil;
while i > 0 do begin
try
AssertNoConflict(Items[i]);
except
on E : ESynMouseCmdError do begin
Delete(i);
if assigned(Owner) and (csDesigning in TComponent(Owner).ComponentState)
then
MessageDlg(SYNS_EDuplicateShortCut, E.Message + LineEnding + Items[i].DisplayName,
mtWarning, [mbOK], '')
else
Err := E;
//if not(assigned(Owner) and (csLoading in TComponent(Owner).ComponentState))
//then
// raise E;
end;
end;
dec(i);
end;
if assigned(Err) then
raise Err;
end;
constructor TSynEditMouseActions.Create(AOwner: TPersistent);
begin
inherited Create(TSynEditMouseAction);
@ -413,7 +445,7 @@ procedure TSynEditMouseActions.AssertNoConflict(MAction: TSynEditMouseAction);
var
i: Integer;
begin
if FAssertLock > 0 then exit;
if (FAssertLock > 0) or (UpdateCount > 0) then exit;
for i := 0 to Count-1 do begin
if Items[i].Conflicts(MAction) then
raise ESynMouseCmdError.Create(SYNS_EDuplicateShortCut);

View File

@ -166,7 +166,7 @@ resourcestring
SYNS_PreviewScrollInfoFmt = 'Page: %d';
// strings for property editors etc
SYNS_EDuplicateShortcut = 'Shortcut already exists';
SYNS_EDuplicateShortcut = 'Mouse-Shortcut already exists';
SYNS_ShortcutNone = '<none>';
SYNS_DuplicateShortcutMsg = 'The keystroke "%s" is already assigned ' +
'to another editor command. (%s)';