View Issue Details

IDProjectCategoryView StatusLast Update
0031192LazarusLCLpublic2018-01-30 05:03
ReporterChris RordenAssigned ToFelipe Monteiro de Carvalho 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformMacBook Retina 13"OSDarwin MacOSOS Version10.11.6
Product Version1.7 (SVN)Product Build53837 
Target VersionFixed in Version1.8 
Summary0031192: Cocoa SpinEdit/FloatSpinEdit do not handle text
DescriptionUnlike other Widgetsets, with Cocoa you can not enter a value into a spinEdit/FloatSpinEdit that is longer than a single digit: whenever you type a digit the value is inserted and the field becomes deselected.
Steps To ReproduceDrop a spin edit on a form. Set project to compile to Cocoa. Run the application. Try to type a new value into the spin edit (e.g. "42") - note that the "4" is written and the rest of the typing is lost.
Additional InformationPlease see attached patch, which appears to fix this issue (though perhaps has unintended consequences).
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetCocoa
Attached Files
  • spinedit_patch.txt (1,431 bytes)
    --- cocoaprivate.pp	2016-10-27 15:36:23.000000000 -0400
    +++ cocoaprivate.pp	2017-01-04 16:51:28.000000000 -0500
    @@ -855,6 +855,7 @@
         procedure PositionSubcontrols(const ALeft, ATop, AWidth, AHeight: Integer); message 'PositionSubcontrols:ATop:AWidth:AHeight:';
         procedure StepperChanged(sender: NSObject); message 'StepperChanged:';
         function GetFieldEditor: TCocoaFieldEditor; message 'GetFieldEditor';
    +    procedure textDidEndEditing(notification: NSNotification); message 'textDidEndEditing:'; override;
         // NSTextFieldDelegateProtocol
         procedure controlTextDidChange(obj: NSNotification); override;
         // lcl
    @@ -4024,6 +4025,20 @@
       end;
     end;
    
    +procedure TCocoaSpinEdit.textDidEndEditing(notification: NSNotification);
    +//procedure TCocoaSpinEdit.EditingDone(event: NSEvent); override;
    +var
    +  lValid: Boolean = False;
    +  lValue: String;
    +  lFloat: Double;
    +begin
    +  lValue := CocoaUtils.NSStringToString(stringValue());
    +  lValid := SysUtils.TryStrToFloat(lValue, lFloat);
    +  if lValid then
    +     Spin.Value := lFloat;
    +  inherited textDidEndEditing(notification);
    +end;
    +
     procedure TCocoaSpinEdit.controlTextDidChange(obj: NSNotification);
     var
       lValid: Boolean = False;
    @@ -4032,7 +4047,8 @@
     begin
       lValue := CocoaUtils.NSStringToString(stringValue());
       lValid := SysUtils.TryStrToFloat(lValue, lFloat);
    -  Spin.Value := lFloat;
    +  if lValid then
    +     stepper.setDoubleValue(lFloat);
     end;
    spinedit_patch.txt (1,431 bytes)

Relationships

related to 0033047 closedDmitry Boyarintsev Cocoa: TSpinEdit value not updated correctly 

Activities

Chris Rorden

2017-01-04 22:58

reporter  

spinedit_patch.txt (1,431 bytes)
--- cocoaprivate.pp	2016-10-27 15:36:23.000000000 -0400
+++ cocoaprivate.pp	2017-01-04 16:51:28.000000000 -0500
@@ -855,6 +855,7 @@
     procedure PositionSubcontrols(const ALeft, ATop, AWidth, AHeight: Integer); message 'PositionSubcontrols:ATop:AWidth:AHeight:';
     procedure StepperChanged(sender: NSObject); message 'StepperChanged:';
     function GetFieldEditor: TCocoaFieldEditor; message 'GetFieldEditor';
+    procedure textDidEndEditing(notification: NSNotification); message 'textDidEndEditing:'; override;
     // NSTextFieldDelegateProtocol
     procedure controlTextDidChange(obj: NSNotification); override;
     // lcl
@@ -4024,6 +4025,20 @@
   end;
 end;

+procedure TCocoaSpinEdit.textDidEndEditing(notification: NSNotification);
+//procedure TCocoaSpinEdit.EditingDone(event: NSEvent); override;
+var
+  lValid: Boolean = False;
+  lValue: String;
+  lFloat: Double;
+begin
+  lValue := CocoaUtils.NSStringToString(stringValue());
+  lValid := SysUtils.TryStrToFloat(lValue, lFloat);
+  if lValid then
+     Spin.Value := lFloat;
+  inherited textDidEndEditing(notification);
+end;
+
 procedure TCocoaSpinEdit.controlTextDidChange(obj: NSNotification);
 var
   lValid: Boolean = False;
@@ -4032,7 +4047,8 @@
 begin
   lValue := CocoaUtils.NSStringToString(stringValue());
   lValid := SysUtils.TryStrToFloat(lValue, lFloat);
-  Spin.Value := lFloat;
+  if lValid then
+     stepper.setDoubleValue(lFloat);
 end;
spinedit_patch.txt (1,431 bytes)

Felipe Monteiro de Carvalho

2017-03-12 21:50

developer   ~0098847

Thanks, I used your idea but implemented it somewhat differently in 54391

Chris Rorden

2018-01-09 16:40

reporter   ~0105540

Fixed.

Issue History

Date Modified Username Field Change
2017-01-04 22:58 Chris Rorden New Issue
2017-01-04 22:58 Chris Rorden File Added: spinedit_patch.txt
2017-01-05 17:39 Felipe Monteiro de Carvalho Assigned To => Felipe Monteiro de Carvalho
2017-01-05 17:39 Felipe Monteiro de Carvalho Status new => assigned
2017-03-12 21:50 Felipe Monteiro de Carvalho LazTarget => -
2017-03-12 21:50 Felipe Monteiro de Carvalho Note Added: 0098847
2017-03-12 21:50 Felipe Monteiro de Carvalho Status assigned => resolved
2017-03-12 21:50 Felipe Monteiro de Carvalho Fixed in Version => 1.8
2017-03-12 21:50 Felipe Monteiro de Carvalho Resolution open => fixed
2018-01-09 16:40 Chris Rorden Note Added: 0105540
2018-01-09 16:40 Chris Rorden Status resolved => closed
2018-01-30 05:03 Dmitry Boyarintsev Relationship added related to 0033047