Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stepper max value ( With correction) #54

Open
Shallowmallow opened this issue Apr 27, 2021 · 1 comment
Open

Stepper max value ( With correction) #54

Shallowmallow opened this issue Apr 27, 2021 · 1 comment

Comments

@Shallowmallow
Copy link
Contributor

On Haxe-ui openfl linux target

If you don't put a max value

The max is considered a 0.

Expected Behavior

If you don't put a max value
<number-stepper pos="30" step="10" width ="30%" />
The max should be considered an infinite

Current Behavior

If you don't put a max value
<number-stepper pos="30" step="10" width ="30%" />
The max is considered a 0.

It's the same problem with minimums

Possible Solution

I haven't checked in detail yet, maybe I'll try in the next few days.
But I suppose the problem is the null value
public var min:Null;
public var max:Null;

Maybe it is considered 0 in MathUtil.clamp
https://github.com/haxeui/haxeui-core/blob/35db371129336a9b592c12997db55b2e4cbd333b/haxe/ui/util/MathUtil.hx#L15-L27

@Shallowmallow
Copy link
Contributor Author

Ok found it.

For some reason, in this function
_stepper.max is equal to 0.

https://github.com/haxeui/haxeui-core/blob/35db371129336a9b592c12997db55b2e4cbd333b/haxe/ui/components/NumberStepper.hx#L265-L274

instead use
var step:Stepper = _component.findComponent("stepper-step", Stepper);
and replace _stepper.min and _stepper.max with step.min and steo.max


    private function onTextFieldFocusOut(event:FocusEvent) {
        _stepper.removeClass(":active");
        var textfield:TextField = _stepper.findComponent("stepper-textfield", TextField);
	var step:Stepper = _stepper.findComponent("stepper-step", Stepper);
        if (textfield != null) {
            _stepper.pos = MathUtil.clamp(Std.parseFloat(textfield.text), step.min, step.max);
            textfield.text = Std.string(_stepper.pos);
        } else {
            event.cancel();
        }
    }

@Shallowmallow Shallowmallow changed the title Stepper max value Stepper max value ( With correction) Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant