mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 20:30:41 +02:00
IDE: Improvements to keymapping buttons' default state and TabOrder.
git-svn-id: trunk@40897 -
This commit is contained in:
parent
8cc723a4a5
commit
4e57eb4fac
@ -1454,6 +1454,7 @@ type
|
||||
private
|
||||
FAllowedShifts: TShiftState;
|
||||
FGrabButton: TButton;
|
||||
FMainOkButton: TCustomButton;
|
||||
FKey: Word;
|
||||
FKeyComboBox: TComboBox;
|
||||
FShiftButtons: TShiftState;
|
||||
@ -1467,15 +1468,13 @@ type
|
||||
procedure SetShiftState(const AValue: TShiftState);
|
||||
procedure OnGrabButtonClick(Sender: TObject);
|
||||
procedure OnShiftCheckBoxClick(Sender: TObject);
|
||||
procedure OnGrabFormKeyDown(Sender: TObject; var AKey: Word;
|
||||
AShift: TShiftState);
|
||||
procedure OnGrabFormKeyDown(Sender: TObject; var AKey: Word; AShift: TShiftState);
|
||||
procedure OnKeyComboboxEditingDone(Sender: TObject);
|
||||
protected
|
||||
procedure Loaded; override;
|
||||
procedure RealSetText(const Value: TCaption); override;
|
||||
procedure UpdateShiftButons;
|
||||
procedure Notification(AComponent: TComponent; Operation: TOperation);
|
||||
override;
|
||||
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
||||
function ShiftToStr(s: TShiftStateEnum): string;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
@ -1486,6 +1485,7 @@ type
|
||||
property AllowedShifts: TShiftState read FAllowedShifts write SetAllowedShifts;
|
||||
property KeyComboBox: TComboBox read FKeyComboBox;
|
||||
property GrabButton: TButton read FGrabButton;
|
||||
property MainOkButton: TCustomButton read FMainOkButton write FMainOkButton;
|
||||
property ShiftCheckBox[Shift: TShiftStateEnum]: TCheckBox read GetShiftCheckBox;
|
||||
end;
|
||||
|
||||
@ -6437,6 +6437,9 @@ begin
|
||||
FGrabForm.Height:=50;
|
||||
FGrabForm.AutoSize:=true;
|
||||
FGrabForm.ShowModal;
|
||||
// After getting a key, focus the main form's OK button. User can just click Enter.
|
||||
if (Key <> VK_UNKNOWN) and Assigned(MainOkButton) then
|
||||
MainOkButton.SetFocus;
|
||||
FreeAndNil(FGrabForm);
|
||||
end;
|
||||
|
||||
@ -6478,8 +6481,7 @@ begin
|
||||
Key:=KeyStringToVKCode(KeyComboBox.Text);
|
||||
end;
|
||||
|
||||
function TCustomShortCutGrabBox.GetShiftCheckBox(Shift: TShiftStateEnum
|
||||
): TCheckBox;
|
||||
function TCustomShortCutGrabBox.GetShiftCheckBox(Shift: TShiftStateEnum): TCheckBox;
|
||||
begin
|
||||
Result:=FCheckBoxes[Shift];
|
||||
end;
|
||||
@ -6607,6 +6609,7 @@ end;
|
||||
constructor TCustomShortCutGrabBox.Create(TheOwner: TComponent);
|
||||
var
|
||||
i: Integer;
|
||||
ShSt: TShiftStateEnum;
|
||||
s: String;
|
||||
begin
|
||||
inherited Create(TheOwner);
|
||||
@ -6648,6 +6651,17 @@ begin
|
||||
ShiftState:=[];
|
||||
Key:=VK_UNKNOWN;
|
||||
KeyComboBox.Text:=KeyAndShiftStateToKeyString(Key,[]);
|
||||
|
||||
// Fix TabOrders. The controls were created in "wrong" order.
|
||||
i:=FGrabButton.TabOrder; // GrabButton was created first.
|
||||
for ShSt:=Low(FCheckBoxes) to High(FCheckBoxes) do begin
|
||||
if Assigned(FCheckBoxes[ShSt]) then begin
|
||||
FCheckBoxes[ShSt].TabOrder:=i;
|
||||
Inc(i);
|
||||
end;
|
||||
end;
|
||||
FKeyComboBox.TabOrder:=i;
|
||||
FGrabButton.TabOrder:=i+1;
|
||||
end;
|
||||
|
||||
function TCustomShortCutGrabBox.GetDefaultShiftButtons: TShiftState;
|
||||
|
@ -10,7 +10,8 @@ object ShortCutDialog: TShortCutDialog
|
||||
ClientHeight = 260
|
||||
ClientWidth = 545
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '0.9.31'
|
||||
OnShow = FormShow
|
||||
LCLVersion = '1.1'
|
||||
object PrimaryGroupBox: TGroupBox
|
||||
Left = 6
|
||||
Height = 93
|
||||
|
@ -46,6 +46,7 @@ type
|
||||
SecondaryGroupBox: TGroupBox;
|
||||
procedure CancelButtonClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure OkButtonClick(Sender: TObject);
|
||||
private
|
||||
FKeyCommandRelationList: TKeyCommandRelationList;
|
||||
@ -83,8 +84,7 @@ type
|
||||
|
||||
function ShowKeyMappingEditForm(Index: integer;
|
||||
AKeyCommandRelationList: TKeyCommandRelationList): TModalResult;
|
||||
function ShowKeyMappingGrabForm(out Key: TIDEShortCut;
|
||||
AllowSequence: boolean = false): TModalResult;
|
||||
function ShowKeyMappingGrabForm(out Key: TIDEShortCut; AllowSequence: boolean = false): TModalResult;
|
||||
|
||||
implementation
|
||||
|
||||
@ -106,8 +106,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function ShowKeyMappingGrabForm(out Key: TIDEShortCut;
|
||||
AllowSequence: boolean): TModalResult;
|
||||
function ShowKeyMappingGrabForm(out Key: TIDEShortCut; AllowSequence: boolean): TModalResult;
|
||||
var
|
||||
ShortCutDialog: TShortCutDialog;
|
||||
begin
|
||||
@ -177,6 +176,11 @@ begin
|
||||
ClearKeys;
|
||||
end;
|
||||
|
||||
procedure TShortCutDialog.FormShow(Sender: TObject);
|
||||
begin
|
||||
FPrimaryKey1Box.GrabButton.SetFocus;
|
||||
end;
|
||||
|
||||
procedure TShortCutDialog.CancelButtonClick(Sender: TObject);
|
||||
begin
|
||||
IDEDialogLayoutList.SaveLayout(Self);
|
||||
@ -264,6 +268,18 @@ begin
|
||||
SecondaryGroupBox.Visible:=FShowSecondary;
|
||||
end;
|
||||
|
||||
procedure TShortCutDialog.SetShowSequence(const AValue: boolean);
|
||||
begin
|
||||
if FShowSequence=AValue then exit;
|
||||
FShowSequence:=AValue;
|
||||
FPrimaryKey2Box.Visible:=FShowSequence;
|
||||
FSecondaryKey2Box.Visible:=FShowSequence;
|
||||
// With a single key GrabBox focus OK button after keypress.
|
||||
if not (FShowSecondary or FShowSequence) then
|
||||
FPrimaryKey1Box.MainOkButton:=BtnPanel.OKButton;
|
||||
UpdateCaptions;
|
||||
end;
|
||||
|
||||
procedure TShortCutDialog.SetPrimaryShortCut(const AValue: TIDEShortCut);
|
||||
var
|
||||
APrimaryShortCut: TIDEShortCut;
|
||||
@ -304,15 +320,6 @@ begin
|
||||
SecondaryKey2Box.ShiftState:=AValue.Shift2;
|
||||
end;
|
||||
|
||||
procedure TShortCutDialog.SetShowSequence(const AValue: boolean);
|
||||
begin
|
||||
if FShowSequence=AValue then exit;
|
||||
FShowSequence:=AValue;
|
||||
FPrimaryKey2Box.Visible:=FShowSequence;
|
||||
FSecondaryKey2Box.Visible:=FShowSequence;
|
||||
UpdateCaptions;
|
||||
end;
|
||||
|
||||
function TShortCutDialog.ResolveConflicts(Key: TIDEShortCut;
|
||||
Scope: TIDECommandScope): TModalResult;
|
||||
type
|
||||
|
Loading…
Reference in New Issue
Block a user