浏览代码

#503 tool shortcuts with cyrillic keyboard

Johann ELSASS 3 年之前
父节点
当前提交
a75ff54419
共有 1 个文件被更改,包括 15 次插入2 次删除
  1. 15 2
      lazpaint/umenu.pas

+ 15 - 2
lazpaint/umenu.pas

@@ -432,18 +432,31 @@ end;
 
 
 procedure TMainFormMenu.CycleTool(var ATool: TPaintToolType;
 procedure TMainFormMenu.CycleTool(var ATool: TPaintToolType;
   var AShortCut: TUTF8Char);
   var AShortCut: TUTF8Char);
+const cyrillicMap = 'ФИСВУАПРШОЛДЬТЩЗЙКЫЕГМЦЧНЯ';
 var
 var
   curTool: TPaintToolType;
   curTool: TPaintToolType;
+  latinShortCut: TUTF8Char;
+  idx: integer;
 begin
 begin
-  AShortCut := UTF8UpperCase(AShortCut);
+  latinShortCut := UTF8UpperCase(AShortCut);
   curTool := ATool;
   curTool := ATool;
+  if (length(latinShortCut) <> 1) or
+    ((length(latinShortCut) = 1) and not (latinShortCut[1] in ['A'..'Z'])) then
+  begin
+    idx := pos(latinShortCut, cyrillicMap);
+    if idx <> 0 then
+    begin
+      idx := UTF8Length(copy(cyrillicMap, 1, idx));
+      latinShortCut := chr(idx+64);
+    end;
+  end;
   repeat
   repeat
     if curTool = high(TPaintToolType) then
     if curTool = high(TPaintToolType) then
       curTool := low(TPaintToolType)
       curTool := low(TPaintToolType)
     else
     else
       curTool := succ(curTool);
       curTool := succ(curTool);
 
 
-    if (FToolsShortcuts[curTool] = AShortCut) and not
+    if (FToolsShortcuts[curTool] = latinShortCut) and not
        ((curTool = ptHotSpot) and not FInstance.Image.IsCursor) then
        ((curTool = ptHotSpot) and not FInstance.Image.IsCursor) then
     begin
     begin
       ATool := curTool;
       ATool := curTool;