Spec icon indicating copy to clipboard operation
Spec copied to clipboard

Validate typing in SpNumberInputFieldPresenter

Open Driolar opened this issue 7 months ago • 5 comments

By typing in a SpNumberInputFieldPresenter field instead of incrementing/decrementing with the up/down arrows, the number range (minimum/maximum) can be duped. The field can also be emptied or filled with wrong characters.

Driolar avatar Jul 25 '25 17:07 Driolar

Thanks for the report. Do you have a little code snippet reproducing the problems?

Ducasse avatar Jul 26 '25 08:07 Ducasse

| boxLayout |
boxLayout := SpBoxLayout newLeftToRight
	             add: (SpNumberInputFieldPresenter new
			              number: 10;
			              minimum: 1;
			              maximum: 15;
			              climbRate: 1;
			              disable;
			              yourself) width: 100;
	             add: SpTextInputFieldPresenter new.
SpPresenter new
	layout: boxLayout;
	open
Image

Note also that #disable is not effective (issue #1798) .

Driolar avatar Jul 26 '25 09:07 Driolar

TX!!!!

Ducasse avatar Jul 26 '25 15:07 Ducasse

holidays! See you end august :P

estebanlm avatar Jul 28 '25 09:07 estebanlm

ok, I am working on this now. this widget has different problems :)

  1. it is not honoring enable/disable, as you are disabling it and it still works
  2. is accepting alpha characters and it shouldn't.
  3. you can type numbers other than the ones in the min/max range.

These are all different problems but I will try to tackle all...

@Driolar first one thing: Never ever create your presenters as you are doing in the example! If you create your presenter as you show there (SpNumberInputFieldPresenter new) you risk creating a presenter outside the POM (Presenter Object Model), and hence you may have a lot of problems...) Instead, you need to instantiate your presenters using newYourPresenter or instantiate: YourPresenterClass methods. e.g., I translated your example to this:

app := SpApplication new.
presenter := SpPresenter newApplication: app.
presenter layout: SpBoxLayout newTopToBottom vAlignStart.

numberInput :=  presenter newNumberInput
	number: 10;
	minimum: 1;
	maximum: 15;
	climbRate: 1;
	yourself.
	
presenter layout add: numberInput.
presenter layout add: presenter newTextInput.
	
presenter open.

estebanlm avatar Nov 04 '25 14:11 estebanlm