Hi,

the attached patch adds shortcut (mnemonic) support for toolbar buttons, makes initial focus in the evaluate dialog go to the input field and makes pressing enter in the input field evaluate it.

--Ere
Index: lcl/comctrls.pp
===================================================================
--- lcl/comctrls.pp     (revision 8136)
+++ lcl/comctrls.pp     (working copy)
@@ -1251,6 +1251,7 @@
     procedure UpdateVisibleToolbar;
     function GroupAllUpAllowed: boolean;
     procedure DoSetBounds(ALeft, ATop, AWidth, AHeight: integer); override;
+    function DialogChar(var Message: TLMKey): boolean; override;
   public
     constructor Create(TheOwner: TComponent); override;
     function CheckMenuDropdown: Boolean; dynamic;
Index: lcl/include/toolbutton.inc
===================================================================
--- lcl/include/toolbutton.inc  (revision 8136)
+++ lcl/include/toolbutton.inc  (working copy)
@@ -163,6 +163,7 @@
   IconPos: TPoint;
   ImgList: TCustomImageList;
   ImgIndex: integer;
+  TS: TTextStyle;
 begin
   //DebugLn('TToolButton.Paint A ',Name,' FToolBar=',DbgS(FToolBar),' 
',ClientWidth,',',ClientHeight,' ',ord(Style));
   if (FToolBar<>nil) and (ClientWidth>0) and (ClientHeight>0) then begin
@@ -245,7 +246,14 @@
 
     // draw text
     if (TextSize.cx>0) then begin
-      Canvas.TextOut(TextPos.X,TextPos.Y,Caption);
+      TS := Canvas.TextStyle;
+      TS.Alignment:= taCenter;
+      TS.Layout:= tlCenter;
+      TS.Opaque:= false;
+      TS.Clipping:= false;
+      TS.SystemFont:=Canvas.Font.IsDefault;
+      TS.ShowPrefix:= true;
+      Canvas.TextRect(PaintRect, TextPos.X, TextPos.Y, Caption, TS);
     end;
 
     // draw separator (at runtime: just space, at designtime: a rectangle)
@@ -732,7 +740,17 @@
   inherited DoSetBounds(ALeft, ATop, AWidth, AHeight);
 end;
 
+function TToolButton.DialogChar(var Message: TLMKey): boolean;
+begin
+  if IsAccel(Message.CharCode, Caption) and CanFocus then
+  begin
+    Click;
+    Result := true;
+  end else
+    Result := inherited;
+end;
 
+
 // included by comctrls.pp
 
 
Index: debugger/evaluatedlg.pp
===================================================================
--- debugger/evaluatedlg.pp     (revision 8136)
+++ debugger/evaluatedlg.pp     (working copy)
@@ -41,6 +41,9 @@
   StdCtrls, DebuggerDlg, BaseDebugManager;
 
 type
+
+  { TEvaluateDlg }
+
   TEvaluateDlg = class(TDebuggerDlg)
     cmbExpression: TComboBox;
     cmbNewValue: TComboBox;
@@ -54,7 +57,9 @@
     tbWatch: TToolButton;
     tbModify: TToolButton;
     tbEvaluate: TToolButton;
+    procedure FormShow(Sender: TObject);
     procedure cmbExpressionChange(Sender: TObject);
+    procedure cmbExpressionKeyPress(Sender: TObject; var Key: char);
     procedure tbEvaluateClick(Sender: TObject);
     procedure tbWatchClick(Sender: TObject);
   private
@@ -76,6 +81,20 @@
 //  tbInspect.Enabled := HasExpression;
 end;
 
+procedure TEvaluateDlg.FormShow(Sender: TObject);
+begin
+  cmbExpression.SetFocus;
+end;
+
+procedure TEvaluateDlg.cmbExpressionKeyPress(Sender: TObject; var Key: char);
+begin
+  if (Key = #13) and tbEvaluate.Enabled
+  then begin
+    tbEvaluate.Click;
+    Key := #0;
+  end;
+end;
+
 procedure TEvaluateDlg.tbEvaluateClick(Sender: TObject);
 var
   S, R: String;

Reply via email to