Commits

Shinya Okano  committed db2aabb

fixed: Updown don't sync enabled property

  • Participants
  • Parent commits c70cf24

Comments (0)

Files changed (1)

File WinSpinEdit.pas

     FMaxValue: Int64;
     FIncrement: Int64;
     FUpDown: TUpDown;
-    FEditable: Boolean;
+    FEditorEnabled: Boolean;
     FOnUpDownChanging: TOnUpDownChanging;
     procedure Clean;
     function GetValue: Int64;
     procedure WMPaste(var Message: TWMPaste); message WM_PASTE;
     procedure WMCut(var Message: TWMCut); message WM_CUT;
   protected
+    function GetEnabled: Boolean; override;
+    procedure SetEnabled(Value: Boolean); override;
     function IsValidChar(Key: Char): Boolean; virtual;
     procedure UpDownClick(Sender: TObject; Button: TUDBtnType); virtual;
     procedure UpDownMouseUp(Sender: TObject; Button: TMouseButton;
     property Ctl3D;
     property DragCursor;
     property DragMode;
-    property Editable: Boolean read FEditable write FEditable default True;
-    property Enabled;
+    property EditorEnabled: Boolean read FEditorEnabled write FEditorEnabled default True;
+    property Enabled read GetEnabled write SetEnabled;
     property Font;
     property Increment: Int64 read FIncrement write FIncrement default 1;
     property MaxLength;
   Value := 0;
   ControlStyle := ControlStyle - [csSetCaption];
   FIncrement := 1;
-  FEditable := True;
+  FEditorEnabled := True;
 end;
 
 destructor TWinSpinEdit.Destroy;
     Result := Result + [ssDouble];
 end;
 
+function TWinSpinEdit.GetEnabled;
+begin
+  Result := inherited GetEnabled;
+end;
+
+procedure TWinSpinEdit.SetEnabled(Value: Boolean);
+begin
+  inherited SetEnabled(Value);
+  FUpDown.Enabled := Value;
+end;
+
 procedure TWinSpinEdit.UpDownClick(Sender: TObject; Button: TUDBtnType);
 begin
   if ReadOnly then
 
 procedure TWinSpinEdit.WMPaste(var Message: TWMPaste);
 begin
-  if not FEditable or ReadOnly then Exit;
+  if not FEditorEnabled or ReadOnly then Exit;
   inherited;
 end;
 
 procedure TWinSpinEdit.WMCut(var Message: TWMPaste);
 begin
-  if not FEditable or ReadOnly then Exit;
+  if not FEditorEnabled or ReadOnly then Exit;
   inherited;
 end;
 
   Result := (Key in [DecimalSeparator, '+', '-', '0'..'9'])
 {$ENDIF}
       or ((Key < #32) and (Key <> Chr(VK_RETURN)));
-  if not FEditable and Result and ((Key >= #32)
+  if not FEditorEnabled and Result and ((Key >= #32)
       or (Key = Char(VK_BACK)) or (Key = Char(VK_DELETE))) then
     Result := False;
 end;