FIX: Alt+Letters typing mode (issue #2785)

This commit is contained in:
Alexander Koblov 2026-03-22 20:48:15 +03:00
commit 55e92df88e
5 changed files with 76 additions and 7 deletions

View file

@ -5,7 +5,7 @@ unit uFileViewBaseGrid;
interface
uses
Classes, SysUtils,
Classes, SysUtils, LCLType,
uFileSource, uFileView, uFileViewWithMainCtrl,
uSmoothScrollingGrid;
@ -29,6 +29,8 @@ type
function CellToIndex(ACol, ARow: Integer): Integer; virtual; abstract;
public
function calcTextHeight: Integer; inline;
function IntfUTF8KeyPress(var UTF8Key: TUTF8Char;
RepeatCount: Integer; SystemKey: Boolean): Boolean; override;
end;
implementation
@ -134,6 +136,17 @@ begin
Result:= self.Canvas.TextHeight('Wg');
end;
function TFileViewBaseGrid.IntfUTF8KeyPress(var UTF8Key: TUTF8Char;
RepeatCount: Integer; SystemKey: Boolean): Boolean;
begin
if SystemKey and Assigned(getFileView) then
begin
if getFileView.IntfUTF8KeyPress(UTF8Key, -1, SystemKey) then
Exit(True);
end;
Result:= inherited IntfUTF8KeyPress(UTF8Key, RepeatCount, SystemKey);
end;
function TFileViewBaseGrid.isMultiColumns: Boolean;
begin
Result:= False;

View file

@ -27,7 +27,7 @@ unit uOrderedFileView;
interface
uses
Classes, SysUtils, Controls, StdCtrls, Menus,
Classes, SysUtils, Controls, StdCtrls, Menus, LCLType,
uTypes,
fQuickSearch,
uFileView,
@ -106,6 +106,8 @@ type
procedure SetActiveFile(aFilePath: String); override; overload;
procedure ChangePathAndSetActiveFile(aFilePath: String); override; overload;
procedure SetFocus; override;
function IntfUTF8KeyPress(var UTF8Key: TUTF8Char;
RepeatCount: Integer; SystemKey: Boolean): Boolean; override;
published // commands
procedure cm_QuickSearch(const Params: array of string);
@ -121,7 +123,7 @@ type
implementation
uses
LCLProc, LCLType, math, Forms, Graphics,
LCLProc, Math, Forms, Graphics,
DCStrUtils,
DCOSUtils,
uLng, uGlobs, uMasks, uDCUtils,
@ -375,6 +377,29 @@ begin
inherited DoHandleKeyDownWhenLoading(Key, Shift);
end;
function TOrderedFileView.IntfUTF8KeyPress(var UTF8Key: TUTF8Char;
RepeatCount: Integer; SystemKey: Boolean): Boolean;
var
AForm: TCustomForm;
begin
if SystemKey and (gKeyTyping[ktmAlt] <> ktaNone) then
begin
AForm:= GetParentForm(Self);
if Assigned(AForm) and AForm.KeyPreview then
begin
if AForm.IntfUTF8KeyPress(UTF8Key, -1, SystemKey) then
Exit(True);
end;
if quickSearch.CheckSearchOrFilter(UTF8Key) then
Exit(True);
end;
if (RepeatCount < 0) then
Result:= False
else begin
Result:= inherited IntfUTF8KeyPress(UTF8Key, RepeatCount, SystemKey);
end;
end;
procedure TOrderedFileView.DoSelectionChanged;
begin
inherited DoSelectionChanged;

View file

@ -934,6 +934,8 @@ type
procedure DoDragDropOperation(Operation: TDragDropOperation;
var DropParams: TDropParams);
function IntfUTF8KeyPress(var UTF8Key: TUTF8Char;
RepeatCount: Integer; SystemKey: Boolean): Boolean; override;
property Drives: TDrivesList read DrivesList;
property SyncChangeDir: String write FSyncChangeDir;
@ -1137,7 +1139,7 @@ begin
Application.AddOnKeyDownBeforeHandler( @GlobalMacOSKeyDownHandler );
{$ENDIF}
{$IF DEFINED(LCLQT5) OR DEFINED(LCLQT6)}
{$IF DEFINED(LCLQT5) OR DEFINED(LCLQT6) OR DEFINED(LCLGTK3)}
// Save original captions
for I:= 0 to mnuMain.Items.Count - 1 do
begin
@ -2090,6 +2092,28 @@ begin
end;
end;
function TfrmMain.IntfUTF8KeyPress(var UTF8Key: TUTF8Char;
RepeatCount: Integer; SystemKey: Boolean): Boolean;
begin
if (RepeatCount < 0) and (gKeyTyping[ktmAlt] = ktaCommandLine) then
begin
if GetKeyShiftStateEx * KeyModifiersShortcutNoText = [ssAlt] then
begin
if FrameLeft.Focused or FrameRight.Focused then
begin
TypeInCommandLine(UTF8Key);
UTF8Key := '';
Exit(True);
end;
end;
end;
if (RepeatCount < 0) then
Result:= False
else begin
Result:= inherited IntfUTF8KeyPress(UTF8Key, RepeatCount, SystemKey);
end;
end;
procedure TfrmMain.FormUTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
begin
// Either left or right panel has to be focused.
@ -5825,7 +5849,7 @@ begin
UpdateFreeSpace(fpRight, True);
end;
{$IF DEFINED(LCLQT5) OR DEFINED(LCLQT6)}
{$IF DEFINED(LCLQT5) OR DEFINED(LCLQT6) OR DEFINED(LCLGTK3)}
// https://github.com/doublecmd/doublecmd/issues/1327
if mnuMain.Tag <> PtrInt(gKeyTyping[ktmAlt]) then
begin

View file

@ -474,6 +474,7 @@ function TfrmQuickSearch.CheckSearchOrFilter(var UTF8Key: TUTF8Char): Boolean;
var
ModifierKeys: TShiftState;
SearchMode: TQuickSearchMode;
KeyTypingModifier: TKeyTypingModifier;
begin
Result := False;
@ -482,9 +483,10 @@ begin
Exit;
ModifierKeys := GetKeyShiftStateEx;
if gKeyTyping[ktmNone] in [ktaQuickSearch, ktaQuickFilter] then
for KeyTypingModifier in [ktmNone, ktmAlt] do
if gKeyTyping[KeyTypingModifier] in [ktaQuickSearch, ktaQuickFilter] then
begin
if ModifierKeys * KeyModifiersShortcutNoText = TKeyTypingModifierToShift[ktmNone] then
if ModifierKeys * KeyModifiersShortcutNoText = TKeyTypingModifierToShift[KeyTypingModifier] then
begin
// Make upper case if either caps-lock is toggled or shift pressed.
if (ssCaps in ModifierKeys) xor (ssShift in ModifierKeys) then

View file

@ -472,6 +472,11 @@ begin
if IsKeyDown(VK_LWIN) or IsKeyDown(VK_RWIN) then
Include(Result, ssMeta);
{$IF DEFINED(X11) and (DEFINED(LCLQT5) OR DEFINED(LCLQT6))}
if IsKeyDown(VK_CAPITAL) then
Include(Result, ssCaps);
{$ENDIF}
if (GetKeyState(VK_CAPITAL) and $1) <> 0 then // Caps-lock toggled
Include(Result, ssCaps);
end;