View Issue Details

IDProjectCategoryView StatusLast Update
0035209LazarusLCLpublic2019-03-13 12:08
ReporterJordi March NoguéAssigned ToBart Broersma 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformWindowsOSWindowsOS Version10
Product VersionProduct Build 
Target Version2.0.2Fixed in Version2.0.2 
Summary0035209: TCustomUpDown bug
DescriptionIn customupdown.inc
function TCustomUpDown.GetPosition: SmallInt;
in line 515:
      else if str[I] in ['0'..'9'] then
must be changed for
      else if (str[I] in ['0'..'9']) or ((I=1) and (str[1]='-')) then
to enable negative integers (when TCustomUpDown.Min <0)

Optionally:
in line 521:
      AV := SmallInt(TruncToInt(StrToFloat(str)))
can be changed for
      AV := StrToInt(str)
(since DefaultFormatSettings.DecimalSeparator is not allowed in str)
TagsNo tags attached.
Fixed in Revisionr60663
LazTarget2.0.2
Widgetset
Attached Files

Activities

Bart Broersma

2019-03-09 12:36

developer   ~0114739

What do you mean with "to enable negative integers (when TCustomUpDown.Min <0)"?
In what situation does this not work?

jamie philbrook

2019-03-09 16:42

reporter   ~0114742

That control works fine with me using 1.8.4 laz, I suspect he maybe using an
old version of Laz because I do remember at some point in the past the
Up/Down didn't go below 0 and was fixed.

Bart Broersma

2019-03-12 17:51

developer   ~0114800

@Jordi March Nogué: adding a note and then deleting it does not count as feedback.
If no feedback is given in a reasonable time this issue will be reolved as "unable to reproduce".

Jordi March Nogué

2019-03-12 19:48

reporter   ~0114801

Last edited: 2019-03-12 22:04

View 2 revisions

Sorry, I had not read the answer until today.
Design time: Create a Form with UpDown1:TUpDown associated to Edit1:TEdit. With UpDown1.Min=-10 (Max=10 and Increment=1).
Run time: TYPE in Edit1.Text '-5' (NOT with clicking UpDown1.FMinBtn or VK_Down). Now click UpDown1.FMaxBtn (Up). Then UpDown1 send to Edit1.Text the number '1' (not the expected number -4) . Why?. TCustomUpDown.GetPosition interprets the number -5 as InvalidNumber=True (because is negative) and then returns the previous value of FPosition=0 (which had not been modified).
Obviously, if you uses only the arrows from UpDown1 and previous positive value runs correctly.

Bart Broersma

2019-03-12 22:52

developer   ~0114803

Yes, I can see that.
It also does that if the text starts with a + sign (which b.t.w. Delphi 7 does also).

Bart Broersma

2019-03-13 12:04

developer   ~0114807

Last edited: 2019-03-13 12:08

View 3 revisions

The fact that UpDown worked with negative numbers at all was pure change.
All negative numbers were treated as invalid and increment/decrement was performed on the last known valid value.
I simplified the code for GetPosition.

Thanks for reporting.
Please test and close if OK.

Issue History

Date Modified Username Field Change
2019-03-08 22:49 Jordi March Nogué New Issue
2019-03-08 22:54 Jonas Maebe Project FPC => Lazarus
2019-03-09 12:36 Bart Broersma LazTarget => -
2019-03-09 12:36 Bart Broersma Note Added: 0114739
2019-03-09 12:36 Bart Broersma Assigned To => Bart Broersma
2019-03-09 12:36 Bart Broersma Status new => feedback
2019-03-09 16:42 jamie philbrook Note Added: 0114742
2019-03-12 12:22 Jordi March Nogué Status feedback => assigned
2019-03-12 17:51 Bart Broersma Note Added: 0114800
2019-03-12 17:51 Bart Broersma Status assigned => feedback
2019-03-12 19:48 Jordi March Nogué Note Added: 0114801
2019-03-12 19:48 Jordi March Nogué Status feedback => assigned
2019-03-12 22:04 Jordi March Nogué Note Edited: 0114801 View Revisions
2019-03-12 22:52 Bart Broersma Note Added: 0114803
2019-03-12 22:52 Bart Broersma Status assigned => confirmed
2019-03-12 22:53 Bart Broersma Status confirmed => assigned
2019-03-13 12:04 Bart Broersma Fixed in Revision => r60663
2019-03-13 12:04 Bart Broersma LazTarget - => 2.0.2
2019-03-13 12:04 Bart Broersma Note Added: 0114807
2019-03-13 12:04 Bart Broersma Status assigned => resolved
2019-03-13 12:04 Bart Broersma Fixed in Version => 2.0.2
2019-03-13 12:04 Bart Broersma Resolution open => fixed
2019-03-13 12:04 Bart Broersma Target Version => 2.0.2
2019-03-13 12:07 Bart Broersma Note Edited: 0114807 View Revisions
2019-03-13 12:08 Bart Broersma Note Edited: 0114807 View Revisions