Recent

Author Topic: 2 Problems with TSpinEdit  (Read 804 times)

chrv

  • Jr. Member
  • **
  • Posts: 58
2 Problems with TSpinEdit
« on: February 18, 2024, 11:09:22 am »
Hi all,

2 problems (see attached)

1/ Why is the NullValue shown at runtime while the value is set to 10 at designtime (and to 20 in FormCreate at runtime) ?
2/ Is it possible to Nullify the TSpinEditEx by code (instead of showine a 0) ?

Thanks all
Win32 Lazarus 2.0.12 FPC 3.2.0

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: 2 Problems with TSpinEdit
« Reply #1 on: February 18, 2024, 03:32:32 pm »
2/ Is it possible to Nullify the TSpinEditEx by code (instead of showine a 0) ?
You "nullify" the control by settingit's value equal to it's NullValue (which is 0 by default).
If Value = NullValue then the NullValueBehaviour controls what is shown in the control.

Bart

jamie

  • Hero Member
  • *****
  • Posts: 6134
Re: 2 Problems with TSpinEdit
« Reply #2 on: February 18, 2024, 03:34:28 pm »
I was going to say something about the version of LAZ 2.0.14 or something like that.

I tested that on 2.0.4 and trunk, it works fine.
The only true wisdom is knowing you know nothing

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: 2 Problems with TSpinEdit
« Reply #3 on: February 18, 2024, 04:05:21 pm »
1/ Why is the NullValue shown at runtime while the value is set to 10 at designtime (and to 20 in FormCreate at runtime) ?
That is in fact a bug.
Fixed in commit 5168d97f.

Thanks for reporting.
Please test and report back.

Bart

chrv

  • Jr. Member
  • **
  • Posts: 58
Re: 2 Problems with TSpinEditEx
« Reply #4 on: February 21, 2024, 10:15:23 pm »
Quote
That is in fact a bug.
Fixed in commit 5168d97f.
@Bart : it works now. Thank you so much ;).

Unfortunately, the other doesn't.
When I set it to NullValue by code with NullValueBehaviour=nvbShowTextHint, in fact it shows "0" (not "MY NULL VALUE" in my case).
Win32 Lazarus 2.0.12 FPC 3.2.0

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: 2 Problems with TSpinEdit
« Reply #5 on: February 21, 2024, 11:47:48 pm »
It's been a while since I wrote that code.
But NullValue etc. are only supposed to come into play when you clear the control (and then leave it).

Explanation: this control initially was intended to replace the standard TSpinEdit's in the IDE's anchor editor, but that never happened.
Notice that a TSpinEdit cannot have an empty text (when you leave the control), but TSpinEditEx can.

If you clear the Text and then query Value, then, if NullValueBehaviour is set to nvbShowTextHint, it will return NullValue.
Notice that NullValue is allowed to be greater than MaxValue or less then MinValue.

So: if you set Value to NullValue, either by code, or by typing the text or using the spinners, the actual value is supposed to be in the control.
In your case, where NullValue = 0, it must show '0' in the control.
This is both at designtime and at runtime.

So, the previous fix I made is wrong.
After the window is initialized, the control's text is empty.
It then calls UpdateControl, causing the the NullValueBehaviour to take effect.
This should not happen (see explanation above).
It should simply show '0'.

I fixed that in commit a3ba11e5.

Bart

 

TinyPortal © 2005-2018