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

Percentages in math ops for number fields #188

Open
LeXXik opened this issue Nov 25, 2020 · 5 comments · Fixed by #385
Open

Percentages in math ops for number fields #188

LeXXik opened this issue Nov 25, 2020 · 5 comments · Fixed by #385
Labels
enhancement New feature or request

Comments

@LeXXik
Copy link
Contributor

LeXXik commented Nov 25, 2020

The current feature of doing math operations, like adding number values in the number fields is super helpful. If possible, please enable adding percentages as well. For example, current value is 123. Allow the use of 123+10%, which would add 10 percent of the current value to the current value.

@willeastcott willeastcott added the enhancement New feature or request label Dec 13, 2020
@willeastcott
Copy link
Contributor

Hey @ellthompson - should I transfer this issue to the PCUI repo, or do you think this request should remain Editor-specific?

@ellthompson
Copy link
Contributor

ellthompson commented Nov 3, 2022

This should be moved to PCUI as it's a feature request for the NumericInput component. We'll need to update the logic here:

this.value = this._domInput.value;

@willeastcott willeastcott transferred this issue from playcanvas/editor Nov 3, 2022
@willeastcott willeastcott reopened this Jan 3, 2025
@willeastcott
Copy link
Contributor

willeastcott commented Jan 3, 2025

So my attempt to implement this was rejected and reverted. Can we be clear about the exact functionality of what's desired here, please?

Is it purely:

  • NumericInput has 200 set.
  • User edits the field to 200 + 10%
  • User presses Enter
  • NumerInput evaluates to 220

Questions:

  • Supported operators would be +, - but should * and /` be allowed?
  • Should expressions work with this?

@Maksims, @LeXXik - please comment.

@Maksims
Copy link
Collaborator

Maksims commented Jan 3, 2025

The addition/subtraction looks correct, yes.
Basically: a + c% = a + (a * c)
Where c is floating representation of a percentage (10% = 0.1; 150% = 1.5; etc).
With multiplication/division, it is even more direct: 200 * 10% = 20, so a * c% = a * c.

@LeXXik
Copy link
Contributor Author

LeXXik commented Jan 3, 2025

Good, good. I think personally, I would go with a bare minimum in this PR. That is I'd just add plus and minus operands, as you described them. Its actually, the operation I wanted originally in this issue. I don't really see a value in mul/div, but perhaps someone is used to use those in some other apps. I'd leave those until a feature request is made, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants