Fixed shortcut bug in the settings dialog (couldn't set hotkeys to BkSp etc.)

Added "Reset" button to shortcuts page
This commit is contained in:
Christian Hammacher 2005-09-05 22:33:45 +00:00
parent e90364c17b
commit 81ab33d794
8 changed files with 109 additions and 26 deletions

View File

@ -115,7 +115,7 @@ AutoIncBuild=1
MajorVer=1
MinorVer=1
Release=0
Build=8
Build=9
Debug=0
PreRelease=0
Special=0
@ -126,7 +126,7 @@ CodePage=1252
[Version Info Keys]
CompanyName=AMX Mod X Dev Team
FileDescription=
FileVersion=1.1.0.8
FileVersion=1.1.0.9
InternalName=
LegalCopyright=
LegalTrademarks=

Binary file not shown.

Binary file not shown.

View File

@ -79,6 +79,7 @@ var lInvalidFile: String;
lCloseCaption: String;
lNoCPP: String;
lInvalidChannel: String;
lResetShortcuts: String;
procedure ResetToEnglish;
@ -161,6 +162,7 @@ begin
lCloseCaption := 'Close';
lNoCPP := 'Sorry, the C++ IDE is not enabled.';
lInvalidChannel := 'Invalid channel.';
lResetShortcuts := 'Warning: The shortcut reset would immediately take affect. Reset anyway?';
end;
end.

View File

@ -903,7 +903,6 @@ begin
end;
procedure TDocCollection.Activate(Document: TDocument; RestoreCaret: Boolean; SaveLastDoc: Boolean = True);
var i: integer;
begin
if not Plugin_DocChange(Document.Index, Document.FileName, Document.Highlighter, RestoreCaret, True) then begin
Started := False;

View File

@ -729,6 +729,7 @@ end;
procedure TfrmMain.FormCreate(Sender: TObject);
begin
end;
{ <- Settings | Toolbars -> }

View File

@ -59,7 +59,7 @@ object frmSettings: TfrmSettings
Top = 0
Width = 353
Height = 260
ActivePage = jspPlugIns
ActivePage = jspShortcuts
PropagateEnable = False
Align = alClient
OnChange = jplSettingsChange
@ -105,7 +105,7 @@ object frmSettings: TfrmSettings
Height = 21
Style = csDropDownList
Color = clWindow
ItemHeight = 0
ItemHeight = 13
TabOrder = 0
ItemIndex = -1
OnChange = cboLanguageChange
@ -662,20 +662,10 @@ object frmSettings: TfrmSettings
OnClick = lvShortcutsClick
OnSelectItem = lvShortcutsSelectItem
end
object hkShortcut: THotKey
Left = 8
Top = 206
Width = 247
Height = 19
Enabled = False
InvalidKeys = []
Modifiers = []
TabOrder = 1
end
object cmdApply: TFlatButton
Left = 263
Left = 173
Top = 205
Width = 85
Width = 84
Height = 20
ColorFocused = 16245198
ColorDown = 16245198
@ -683,9 +673,34 @@ object frmSettings: TfrmSettings
ColorShadow = 8623776
Caption = 'Apply'
Enabled = False
TabOrder = 2
TabOrder = 1
OnClick = cmdApplyClick
end
object cmdResetShortcuts: TFlatButton
Left = 261
Top = 205
Width = 85
Height = 20
ColorFocused = 16245198
ColorDown = 16245198
ColorHighLight = 8623776
ColorShadow = 8623776
Caption = 'Reset'
TabOrder = 2
OnClick = cmdResetShortcutsClick
end
object txtShortcut: TFlatEdit
Left = 8
Top = 206
Width = 159
Height = 19
ColorFlat = clWhite
TabOrder = 3
Text = 'None'
OnKeyDown = txtShortcutKeyDown
OnKeyPress = txtShortcutKeyPress
OnKeyUp = txtShortcutKeyUp
end
end
object jspCodeSnippets: TJvStandardPage
Left = 0
@ -777,9 +792,9 @@ object frmSettings: TfrmSettings
object lblPAWN: TLabel
Left = 8
Top = 12
Width = 79
Width = 75
Height = 13
Caption = 'PAWN-Compiler:'
Caption = 'Pawn-Compiler:'
end
object lblCPPCompiler: TLabel
Left = 8
@ -1657,11 +1672,11 @@ object frmSettings: TfrmSettings
end
object odBrowse: TOpenDialog
Filter = 'Executables (*.exe)|*.exe|All files (*.*)|*.*'
Left = 441
Left = 455
Top = 2
end
object ilImages: TImageList
Left = 410
Left = 424
Top = 2
Bitmap = {
494C010102000400040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600

View File

@ -73,7 +73,6 @@ type
cboCodeFolding: TFlatComboBox;
lblCodeFoldingStyle: TLabel;
lvShortcuts: TListView;
hkShortcut: THotKey;
cmdApply: TFlatButton;
shpShortcuts: TShape;
ftcCodeSnippets: TFlatTabControl;
@ -184,6 +183,8 @@ type
txtAMXXDir: TFlatEdit;
lblAMXXDir: TLabel;
cmdBrowseAMXXDir: TFlatButton;
cmdResetShortcuts: TFlatButton;
txtShortcut: TFlatEdit;
procedure jplSettingsChange(Sender: TObject);
procedure txtLinesChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
@ -243,6 +244,12 @@ type
procedure cmdLoadClick(Sender: TObject);
procedure cmdRemoveClick(Sender: TObject);
procedure cmdBrowseAMXXDirClick(Sender: TObject);
procedure txtShortcutKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure txtShortcutKeyPress(Sender: TObject; var Key: Char);
procedure cmdResetShortcutsClick(Sender: TObject);
procedure txtShortcutKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
public
Foreground, Background: TColor;
CaretFore, CaretBack: TColor;
@ -485,9 +492,9 @@ end;
procedure TfrmSettings.lvShortcutsClick(Sender: TObject);
begin
cmdApply.Enabled := Assigned(lvShortcuts.Selected);
hkShortcut.Enabled := cmdApply.Enabled;
txtShortcut.Enabled := cmdApply.Enabled;
if cmdApply.Enabled then
hkShortcut.HotKey := TextToShortCut(lvShortcuts.Selected.Subitems[0]);
txtShortcut.Text := lvShortcuts.Selected.Subitems[0];
end;
procedure TfrmSettings.trvSettingsChanging(Sender: TObject;
@ -536,7 +543,7 @@ end;
procedure TfrmSettings.cmdApplyClick(Sender: TObject);
begin
if Assigned(lvShortcuts.Selected) then
lvShortcuts.Selected.SubItems[0] := ShortcutToText(hkShortcut.HotKey);
lvShortcuts.Selected.SubItems[0] := txtShortcut.Text;
end;
procedure TfrmSettings.cmdSelectForegroundClick(Sender: TObject);
@ -946,4 +953,63 @@ begin
txtAMXXDir.Text := eStr;
end;
procedure TfrmSettings.txtShortcutKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key = VK_SHIFT) or (Key = VK_CONTROL) or (Key = VK_MENU) then begin
txtShortcut.Clear;
if ssShift in Shift then
txtShortcut.Text := txtShortcut.Text + 'Shift+';
if ssCtrl in Shift then
txtShortcut.Text := txtShortcut.Text + 'Ctrl+';
if ssAlt in Shift then
txtShortcut.Text := txtShortcut.Text + 'Alt+';
Key := 0;
end
else
txtShortcut.Text := ShortcutToText(Shortcut(Key, Shift));
end;
procedure TfrmSettings.txtShortcutKeyPress(Sender: TObject; var Key: Char);
begin
Key := #0;
end;
procedure TfrmSettings.cmdResetShortcutsClick(Sender: TObject);
var i: integer;
Item: TListItem;
KeyCommand: TSciKeyCommand;
Ident: String;
begin
if MessageBox(Handle, PChar(lResetShortcuts), PChar(Application.Title), MB_ICONQUESTION + MB_YESNO) = mrYes then begin
frmMain.sciEditor.KeyCommands.ResetDefaultCommands;
frmSettings.lvShortcuts.Items.BeginUpdate;
try
frmSettings.lvShortcuts.Clear;
for i := 0 to frmMain.sciEditor.KeyCommands.Count - 1 do begin
KeyCommand := frmMain.sciEditor.KeyCommands.Items[i] as TSciKeyCommand;
Ident := 'Unknown';
IntToIdent(KeyCommand.Command, Ident, Sci_KeyboardCommandMap);
if Ident <> 'No Command' then begin // Important for Control Chars, the user mustn't change the values for it...
Item := frmSettings.lvShortcuts.Items.Add;
Item.Caption:= Ident;
Item.SubItems.Add(ShortCutToText(KeyCommand.ShortCut));
Item.Data := KeyCommand;
end;
end;
finally
frmSettings.lvShortcuts.Items.EndUpdate;
end;
end;
end;
procedure TfrmSettings.txtShortcutKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key = VK_SHIFT) or (Key = VK_CONTROL) or (Key = VK_MENU) then begin
if txtShortcut.Text[Length(txtShortcut.Text)] = '+' then
txtShortcut.Text := 'None';
end;
end;
end.