FIX: Bug [0001749] MacOS-style Hotkeys to search text in viewer

This commit is contained in:
Alexander Koblov 2017-08-13 20:35:21 +00:00
commit 33f56b56c3
3 changed files with 46 additions and 45 deletions

View file

@ -45,6 +45,7 @@ const
SmkcNumMultiply = 'Num*';
SmkcNumAdd = 'Num+';
SmkcNumSubstract = 'Num-';
SmkcSuper = {$IF DEFINED(DARWIN)}SmkcWin{$ELSE}SmkcCtrl{$ENDIF};
MenuKeyCaps: array[TMenuKeyCap] of string = (
SmkcClear, SmkcBkSp, SmkcTab, SmkcEsc, SmkcEnter, SmkcSpace, SmkcPgUp,
@ -112,6 +113,8 @@ const
ExcludeShiftState: TShiftState = []): TUTF8Char;
{$ENDIF}
function IsShortcutConflictingWithOS(Shortcut: String): Boolean;
{en
Initializes keyboard module.
Should be called after Application.Initialize.
@ -1142,6 +1145,46 @@ begin
{$ENDIF}
end;
function IsShortcutConflictingWithOS(Shortcut: String): Boolean;
const
ConflictingShortcuts: array [0..27] of String =
(SmkcBkSp, // Delete previous character
SmkcDel, // Delete next character
SmkcLeft, // Move cursor left
SmkcRight, // Move cursor right
SmkcSpace, // Space
SmkcWin, // Context menu
SmkcShift + 'F10', // Context menu
SmkcShift + SmkcDel, // Cut text
SmkcShift + SmkcIns, // Paste text
SmkcShift + SmkcHome, // Select to beginning
SmkcShift + SmkcEnd, // Select to end
SmkcShift + SmkcLeft, // Select previous character
SmkcShift + SmkcRight, // Select next character
SmkcSuper + 'A', // Select all
SmkcSuper + 'C', // Copy text
SmkcSuper + 'V', // Paste text
SmkcSuper + 'X', // Cut text
SmkcSuper + 'Z', // Undo
SmkcSuper + SmkcBkSp, // Delete previous word
SmkcSuper + SmkcDel, // Delete next word
SmkcSuper + SmkcIns, // Copy text
SmkcSuper + SmkcHome, // Move to beginning
SmkcSuper + SmkcEnd, // Move to end
SmkcSuper + SmkcLeft, // Move to beginning of word
SmkcSuper + SmkcRight, // Move to end of word
SmkcSuper + SmkcShift + 'Z', // Redo
SmkcSuper + SmkcShift + SmkcLeft, // Select to beginning of word
SmkcSuper + SmkcShift + SmkcRight); // Select to end of word
var
i: Integer;
begin
for i := Low(ConflictingShortcuts) to High(ConflictingShortcuts) do
if Shortcut = ConflictingShortcuts[i] then
Exit(True);
Result := False;
end;
procedure InitializeKeyboard;
begin
OnKeyboardLayoutChanged;

View file

@ -985,9 +985,9 @@ begin
'Esc','',''],'cm_ExitViewer');
AddIfNotExists(['F' ,'','',
'Ctrl+F' ,'','',
'F7' ,'',''],'cm_Find'); // , ['F'], []);
AddIfNotExists(['F' ,'','',
SmkcSuper + 'F' ,'','',
'F7' ,'',''],'cm_Find'); // , ['F'], []);
AddIfNotExists(['F3'],[],'cm_FindNext');
AddIfNotExists(['Shift+F3'],[],'cm_FindPrev');

View file

@ -209,8 +209,6 @@ type
procedure Save(Config: TXmlConfig; Root: TXmlNode);
procedure Load(Config: TXmlConfig; Root: TXmlNode);
procedure LoadIni(FileName: String);
//---------------------
function IsShortcutConflictingWithOS(Shortcut: String): Boolean;
public
constructor Create;
destructor Destroy; override;
@ -1077,46 +1075,6 @@ begin
FreeAndNil(ini);
end;
function THotKeyManager.IsShortcutConflictingWithOS(Shortcut: String): Boolean;
const
ConflictingShortcuts: array [0..27] of String =
(SmkcBkSp, // Delete previous character
SmkcDel, // Delete next character
SmkcLeft, // Move cursor left
SmkcRight, // Move cursor right
SmkcSpace, // Space
SmkcWin, // Context menu
SmkcShift + 'F10', // Context menu
SmkcShift + SmkcDel, // Cut text
SmkcShift + SmkcIns, // Paste text
SmkcShift + SmkcHome, // Select to beginning
SmkcShift + SmkcEnd, // Select to end
SmkcShift + SmkcLeft, // Select previous character
SmkcShift + SmkcRight, // Select next character
SmkcCtrl + 'A', // Select all
SmkcCtrl + 'C', // Copy text
SmkcCtrl + 'V', // Paste text
SmkcCtrl + 'X', // Cut text
SmkcCtrl + 'Z', // Undo
SmkcCtrl + SmkcBkSp, // Delete previous word
SmkcCtrl + SmkcDel, // Delete next word
SmkcCtrl + SmkcIns, // Copy text
SmkcCtrl + SmkcHome, // Move to beginning
SmkcCtrl + SmkcEnd, // Move to end
SmkcCtrl + SmkcLeft, // Move to beginning of word
SmkcCtrl + SmkcRight, // Move to end of word
SmkcCtrl + SmkcShift + 'Z', // Redo
SmkcCtrl + SmkcShift + SmkcLeft, // Select to beginning of word
SmkcCtrl + SmkcShift + SmkcRight); // Select to end of word
var
i: Integer;
begin
for i := Low(ConflictingShortcuts) to High(ConflictingShortcuts) do
if Shortcut = ConflictingShortcuts[i] then
Exit(True);
Result := False;
end;
function THotKeyManager.Register(AForm: TCustomForm; AFormName: String): THMForm;
var
formInstance: THMFormInstance;