Giter VIP home page Giter VIP logo

Comments (3)

tmedwards avatar tmedwards commented on June 15, 2024

I'm going to assume that you're referring to the <<numberbox>> macro that was first added to the standard library in v.2.32.0 and updated in v.2.33.0. I'll be referring to the latest public version.

I have some suggestions for improvements to this macro:

Considering that the macro's actual UI widget is an <input type="number"> element, most of your suggestions are probably going to need to be filed with (a) the standards groups and/or (b) the browser manufacturers. If I don't specifically reply to something below, then that's the case—or I consider it such, anyway.

Additionally. As is often the case, the <input type="number"> UI is not consistent across browsers, so some of your complaints are not cross-browser—in particular, Gecko and Blink have very different behavior here. E.g., Chrome does not allow any letters to be entered—aside from the scientific notation e.

  • It considers a decimal point to be an error unless it's .0 -- I think these should be configurable validation settings. Sometimes you want to real numbers, sometimes you only want integers.
  • It doesn't let you specify a valid range -- I think more often than not, there is a valid range and an invalid range. It would be nice if the macro allowed you to specify it. You should not be able to use numbers outside of this range.

These are possible to address in SugarCube, but may not be in v2 due to argument list issues. Additionally, some, like range, can be checked by user code post-input.

  • It saves a string into the variable, making it inconvenient to implement custom range validation. -- I think the variable should be a number type

I'm unsure what you think you're seeing, but it only stores numbers within the receiver variable. Beyond that, no browser that I know of writes non-numbers to the field value of an <input type="number">, so <<numberbox>> never even sees non-numbers to begin with.

from sugarcube-3.

tmedwards avatar tmedwards commented on June 15, 2024

Browsers (chiefly Firefox ) should no longer flag decimal numbers as invalid in the next release.

from sugarcube-3.

tmedwards avatar tmedwards commented on June 15, 2024

With the recent inputmode change (commit tmedwards/sugarcube-2@a9984f9), I've done about as much as I can do for <<numberbox>> in v2 without introducing breaking changes. Thus, I'm going to move this issue over to the v3 repo.

from sugarcube-3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.