Recent

Author Topic: (Solved simpler)Wrap around option for SpinEdit and FloatSpinEdit  (Read 1412 times)

jamie

  • Hero Member
  • *****
  • Posts: 3664
recently I have been using these controls to set values where there is a range to work with and thus would like for them to wrap around automatically..

 It would be nice if we have a option property to set if the control is allowed to wrap around to the + or - side back to their Min/Max settings while the user is scrolling with the up/down arrows..

 Currently I have it set with one more and less than the desired value so when user gets to these ranges I use the OnChange event and change the value back to the roll over values. This works but it causes a little GUI glitter.

 Also, if the user directly types the values they are allowed to type in the extended values I put in there for the roll over hack I have but this leads confusing to the user into thinking there is something wrong.
 
 All of which causes GUI glitter.

 Unless I missed something, I don't see a property to set the desired effect if the user rolls to the limits ?
« Last Edit: December 01, 2019, 12:47:04 am by jamie »
The only true wisdom is knowing you know nothing

Bart

  • Hero Member
  • *****
  • Posts: 3943
    • Bart en Mariska's Webstek
Re: Wrap around option for SpinEdit and FloatSpinEdit
« Reply #1 on: November 24, 2019, 11:27:55 pm »
Maybe you could create a patch that implements this?
The functionality must be off by default (for Delphi compatibility).

I suspect it might be easier to implement this in T(Float)SpinEditEx.

Bart

zeljko

  • Hero Member
  • *****
  • Posts: 1149
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Wrap around option for SpinEdit and FloatSpinEdit
« Reply #2 on: November 30, 2019, 11:33:33 am »
Qt/Qt5 native QSpinBox, QDoubleSpinBox have wrapAround property, so easy to implement if LCL have wrapAround support.

jamie

  • Hero Member
  • *****
  • Posts: 3664
Re: Wrap around option for SpinEdit and FloatSpinEdit
« Reply #3 on: November 30, 2019, 08:20:01 pm »
I guess I could write a helper or local class hack to experiment on that.. After that it could be integrated into the control if behavior is accepted.

 Currently I use it for degree rotation calculations where I want the user to be able to just keep going and have it start on the other side. The app also has a visual view of this, too!.

 Currently my hack isn't clean but it gets them on the road.

 I use the Mod operator if they type in a value over the range so that a direct entry can be calculated with proper wrap around. I suppose that too should be optionally set as to how that behaves.
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 3664
Re: Wrap around option for SpinEdit and FloatSpinEdit
« Reply #4 on: December 01, 2019, 12:25:19 am »
Maybe you could create a patch that implements this?
The functionality must be off by default (for Delphi compatibility).

I suspect it might be easier to implement this in T(Float)SpinEditEx.

Bart

Patch not needed, I realized I can do it smoothly doing this.

Set the Min/max range to 0

and implement this this.
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FloatSpinEdit1Change(Sender: TObject);
  2.  begin
  3.    With TFloatSpinEdit(Sender) do
  4.     begin
  5.       If value >=360 Then Value := (Round(value *100) Mod 36000) * 0.01 else
  6.         if Value < 0.0 then value := 359.99;
  7.     end;
  8.  end;                                      
  9.  

 I can also use the MOD for the - side but not needed here. This seems to work with less glitter..
« Last Edit: December 01, 2019, 12:43:15 am by jamie »
The only true wisdom is knowing you know nothing

Alexandr R

  • New Member
  • *
  • Posts: 20
Re: (Solved simpler)Wrap around option for SpinEdit and FloatSpinEdit
« Reply #5 on: February 08, 2020, 07:59:16 pm »
look here   //yadi.sk/d/tSgE1a9vRbc-Lg

 

TinyPortal © 2005-2018