Jelajahi Sumber

I key to insert point for polygon and edit shape

circular17 6 tahun lalu
induk
melakukan
0dafa56f9e
2 mengubah file dengan 35 tambahan dan 13 penghapusan
  1. 17 9
      lazpaint/tools/utoolpolygon.pas
  2. 18 4
      lazpaint/tools/utoolvectorial.pas

+ 17 - 9
lazpaint/tools/utoolpolygon.pas

@@ -38,6 +38,7 @@ type
     procedure AssignShapeStyle(AMatrix: TAffineMatrix); override;
     procedure UpdateUserMode; virtual;
   public
+    function ToolKeyPress(var key: TUTF8Char): TRect; override;
     function GetContextualToolbars: TContextualToolbars; override;
   end;
 
@@ -152,7 +153,6 @@ begin
 end;
 
 function TToolSpline.ToolKeyPress(var key: TUTF8Char): TRect;
-var keyCode: Word;
 begin
   if (Key='z') or (Key = 'Z') then
   begin
@@ -160,14 +160,6 @@ begin
     result := OnlyRenderChange;
     Key := #0;
   end else
-  if (Key='i') or (Key='I') then
-  begin
-    keyCode := VK_INSERT;
-    ToolKeyDown(keyCode);
-    keyCode := VK_INSERT;
-    ToolKeyUp(keyCode);
-    result := EmptyRect;
-  end else
   begin
     Result:=inherited ToolKeyPress(key);
     if Key='x' then Key := #0;
@@ -203,6 +195,22 @@ begin
   if FQuickDefine then FShape.Usermode := vsuCreate;
 end;
 
+function TToolPolygon.ToolKeyPress(var key: TUTF8Char): TRect;
+var
+  keyCode: Word;
+begin
+  if (Key='i') or (Key='I') then
+  begin
+    keyCode := VK_INSERT;
+    ToolKeyDown(keyCode);
+    if keyCode = 0 then key := #0;
+    keyCode := VK_INSERT;
+    ToolKeyUp(keyCode);
+    result := EmptyRect;
+  end else
+    Result:=inherited ToolKeyPress(key);
+end;
+
 function TToolPolygon.GetContextualToolbars: TContextualToolbars;
 begin
   Result:= [ctColor,ctTexture,ctShape,ctPenWidth,ctPenStyle,ctJoinStyle,ctLineCap];

+ 18 - 4
lazpaint/tools/utoolvectorial.pas

@@ -998,14 +998,28 @@ end;
 function TEditShapeTool.ToolKeyPress(var key: TUTF8Char): TRect;
 var
   handled: boolean;
+  keyCode: word;
 begin
   Result:= EmptyRect;
   if GetEditMode in [esmShape,esmNoShape] then
   begin
-    BindOriginalEvent(true);
-    Manager.Image.CurrentState.LayeredBitmap.KeyPress(key, handled);
-    if handled then key := #0;
-    BindOriginalEvent(false);
+    if Assigned(GetVectorOriginal.SelectedShape) and
+      (GetVectorOriginal.SelectedShape is TCustomPolypointShape) and
+      ((Key='i') or (Key='I')) then
+    begin
+      keyCode := VK_INSERT;
+      ToolKeyDown(keyCode);
+      if keyCode = 0 then key := #0;
+      keyCode := VK_INSERT;
+      ToolKeyUp(keyCode);
+      result := EmptyRect;
+    end else
+    begin
+      BindOriginalEvent(true);
+      Manager.Image.CurrentState.LayeredBitmap.KeyPress(key, handled);
+      if handled then key := #0;
+      BindOriginalEvent(false);
+    end;
   end;
 end;