Allow JS expressions in number inputs by dogboydog · Pull Request #4234 · mapeditor/tiled (original) (raw)

dogboydog

dogboydog

@dogboydog

…ript dialog and custom properties view

@dogboydog

@dogboydog

@bjorn

@bjorn

Not really sure what difference this makes, though. It might have some visualization potential.

@bjorn

QSpinBox::setValue and QDoubleSpinBox::setValue cause the text to get reset to the current value, but we don't want to do this while the user is still typing. So compare values first to not call setValue needlessly.

@bjorn

DoubleSpinBox is always an ExpressionDoubleSpinBox.

@bjorn

Actually this is called a bit too much to be executing JS. It also gets called when plain number values are set on the spin box, for example during initialization.

@bjorn

This way the prefix/suffix does not get in the way of typing and we don't need to parse out the prefix/suffix before evaluating the text.

Also simplified the ExpressionEvaluator class a little.

@dogboydog

@bjorn

@bjorn bjorn mentioned this pull request

Feb 23, 2026

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})