You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Justin Mclean <ju...@classsoftware.com> on 2013/09/12 08:24:44 UTC
Spark NumericSpinner patch to fix extra digits showing
Hi,
Someone mind trying out this patch for the spark NumericSpinner?
diff --git a/frameworks/projects/spark/src/spark/components/NumericStepper.as b/frameworks/projects/spark/src/spark/components/NumericStepper.as
index 6a45b32..02d0ebf 100644
--- a/frameworks/projects/spark/src/spark/components/NumericStepper.as
+++ b/frameworks/projects/spark/src/spark/components/NumericStepper.as
@@ -796,6 +796,7 @@ public class NumericStepper extends Spinner
if (dataFormatter == null)
{
dataFormatter = new NumberFormatter();
+ dataFormatter.fractionalDigits = Math.max(0, (stepSize - Math.floor(stepSize)).toString().length - 2);
addStyleClient(dataFormatter);
}
And see if it fixes this issue:
https://issues.apache.org/jira/browse/FLEX-33657
Thanks,
Justin
Re: Spark NumericSpinner patch to fix extra digits showing
Posted by OmPrakash Muppirala <bi...@gmail.com>.
On Thu, Sep 12, 2013 at 1:59 AM, Justin Mclean <ju...@classsoftware.com>wrote:
> Hi,
>
> > I ran the tests under tests/components/NumericStepper. No failures
> > reported.
>
> Think they are the mx ones you want to run:
> ./mini_run.sh tests/gumbo/components/NumericStepper
>
>
Ah sorry, got confused. Its 2AM here. I think I need to wrap up and get
some sleep.
> All pass btw and I've checked the code in.
>
>
Great!
> > I see that there is a test_changes.sh script. How would I run that?
> Alex mentioned it the other day but it requires quite a few steps, mostly
> undocumented, to set up, so I've not tried it.
>
>
I did a search for test_changes.sh in my gmail - nothing much shows up.
Can you point me to relevant discussion?
Thanks,
Om
> Thanks,
> Justin
Re: Spark NumericSpinner patch to fix extra digits showing
Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,
> I ran the tests under tests/components/NumericStepper. No failures
> reported.
Think they are the mx ones you want to run:
./mini_run.sh tests/gumbo/components/NumericStepper
All pass btw and I've checked the code in.
> I see that there is a test_changes.sh script. How would I run that?
Alex mentioned it the other day but it requires quite a few steps, mostly undocumented, to set up, so I've not tried it.
Thanks,
Justin
Re: Spark NumericSpinner patch to fix extra digits showing
Posted by OmPrakash Muppirala <bi...@gmail.com>.
10 and 100 works fine too.
I ran the tests under tests/components/NumericStepper. No failures
reported.
I see that there is a test_changes.sh script. How would I run that?
Thanks,
Om
On Thu, Sep 12, 2013 at 12:52 AM, Justin Mclean <ju...@classsoftware.com>wrote:
> Hi,
>
> > I can confirm that the patch works. When I click on the stepper buttons,
> > it does not show the decimal point or extra digits.
> > Also confirmed that if I set stepSize=0.1, the expected behavior works as
> > well.
>
> Could you try a step size of 10 or 100? I tested this here but obviously
> could only test so much as the issue doesn't occur on OSX.
>
> How's the mustella tests after that patch? I'd assume we'd have a few
> failures?
>
> Thanks,
> Justin
Re: Spark NumericSpinner patch to fix extra digits showing
Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,
> I can confirm that the patch works. When I click on the stepper buttons,
> it does not show the decimal point or extra digits.
> Also confirmed that if I set stepSize=0.1, the expected behavior works as
> well.
Could you try a step size of 10 or 100? I tested this here but obviously could only test so much as the issue doesn't occur on OSX.
How's the mustella tests after that patch? I'd assume we'd have a few failures?
Thanks,
Justin
Re: Spark NumericSpinner patch to fix extra digits showing
Posted by OmPrakash Muppirala <bi...@gmail.com>.
I can confirm that the patch works. When I click on the stepper buttons,
it does not show the decimal point or extra digits.
Also confirmed that if I set stepSize=0.1, the expected behavior works as
well.
Thanks,
Om
On Thu, Sep 12, 2013 at 12:01 AM, Justin Mclean <ju...@classsoftware.com>wrote:
> Hi,
>
> Thanks, much appreciated, and of course I meant NumericStepper not
> NumericSpinner :-)
>
> Justin
Re: Spark NumericSpinner patch to fix extra digits showing
Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,
Thanks, much appreciated, and of course I meant NumericStepper not NumericSpinner :-)
Justin
Re: Spark NumericSpinner patch to fix extra digits showing
Posted by OmPrakash Muppirala <bi...@gmail.com>.
On it...
On Wed, Sep 11, 2013 at 11:24 PM, Justin Mclean <ju...@classsoftware.com>wrote:
> Hi,
>
> Someone mind trying out this patch for the spark NumericSpinner?
>
> diff --git
> a/frameworks/projects/spark/src/spark/components/NumericStepper.as
> b/frameworks/projects/spark/src/spark/components/NumericStepper.as
> index 6a45b32..02d0ebf 100644
> --- a/frameworks/projects/spark/src/spark/components/NumericStepper.as
> +++ b/frameworks/projects/spark/src/spark/components/NumericStepper.as
> @@ -796,6 +796,7 @@ public class NumericStepper extends Spinner
> if (dataFormatter == null)
> {
> dataFormatter = new NumberFormatter();
> + dataFormatter.fractionalDigits =
> Math.max(0, (stepSize - Math.floor(stepSize)).toString().length - 2);
> addStyleClient(dataFormatter);
> }
>
>
> And see if it fixes this issue:
> https://issues.apache.org/jira/browse/FLEX-33657
>
> Thanks,
> Justin
Re: Spark NumericSpinner patch to fix extra digits showing
Posted by Alex Harui <ah...@adobe.com>.
I did some more digging.
At some point, NumericStepper calls NumberFormatter. I believe there is a
bug in that logic because the NumberFormatter does not get created until
you hit the up/down buttons.
Anyway, the NumberFormatter creates an instance of
flash.globalization.NumberFormatter. On Windows, it has
fractionalDigits=2 and trailingZeros=true, on Mac, it has
fractionalDigits=3 and trailingZeros=false. The documentation says that
default values are os-specific.
So, IMO, this issue isn't just about setting fractionalDigits to 0 but
also setting trailingZeros=false.
The puzzling thing to me is that, NumberFormatter is based on
GlobalizationBase which has a lot of code for being a non-display object
that supports styles, but I don't see any code that propagates the default
styles to the NumberFormatter. That's what seems wrong to me. If there
was code at instantiation time that got the styles for every property on
NumberFormatter, then folks should be able to set default styles in the
defaults.css or elsewhere and have that affect formatting in their app.
So, I think that's what should be fixed, and then the global selector
should have trailingZeros=false and this problem would go away and we
wouldn't have to tie the number of fractional digits to the stepSize.
Thoughts?
-Alex
On 9/12/13 9:50 PM, "Alex Harui" <ah...@adobe.com> wrote:
>I'm concerned we're going to break someone's app.
>
>Another scenario I thought of was the 50 cent scenario where you set the
>step size to .5 but want to show 2 digits of cents. Yes, they can fix
>their apps, but I don't like doing that to people.
>
>I think I'll drag out my Windows computer and see what FP 11.1 does.
>
>-Alex
>
>On 9/12/13 3:05 PM, "Justin Mclean" <ju...@classsoftware.com> wrote:
>
>>Hi,
>>
>>> Clever idea. I didn't try it but from looking at this diff, I wonder
>>>if
>>> it is ok to tie the number of decimal places to the step size.
>>In most cases (that I can think of) it is. It certainly better than what
>>it's currently doing.
>>
>>> Couldn't there be a difference like stepping by whole dollars but
>>>wanting to show
>>> cents
>>Can be done by setting the valueFormatFunction.
>>
>>> maybe starting at some fractional value but stepping by whole
>>> integers,
>>Then you need the decimal places 1.05, 2.05, 3.05 etc ect
>>
>>> or having the step size have more decimal places but show fewer
>>> in order to deal with round off?
>>Again you could use valuFormatFunction.
>>
>>What might be a better idea is if the class accepted a user defined data
>>formatter rather than having dataFormatter as private and in settable.
>>
>>> Do we know if we're using the right "field" from the globalization
>>> classes? Is it a bug in the player we are working around?
>>It probably is a bug as it only happens on Windows, I'd assuming it's
>>getting the 2 decimal places from the locale currency format and using
>>that as the default.
>>
>>It may also be that this is a bug only shows up in recent Flash Player
>>versions on windows.
>>
>>Thanks,
>>Justin
>
Re: Spark NumericSpinner patch to fix extra digits showing
Posted by Alex Harui <ah...@adobe.com>.
I'm concerned we're going to break someone's app.
Another scenario I thought of was the 50 cent scenario where you set the
step size to .5 but want to show 2 digits of cents. Yes, they can fix
their apps, but I don't like doing that to people.
I think I'll drag out my Windows computer and see what FP 11.1 does.
-Alex
On 9/12/13 3:05 PM, "Justin Mclean" <ju...@classsoftware.com> wrote:
>Hi,
>
>> Clever idea. I didn't try it but from looking at this diff, I wonder if
>> it is ok to tie the number of decimal places to the step size.
>In most cases (that I can think of) it is. It certainly better than what
>it's currently doing.
>
>> Couldn't there be a difference like stepping by whole dollars but
>>wanting to show
>> cents
>Can be done by setting the valueFormatFunction.
>
>> maybe starting at some fractional value but stepping by whole
>> integers,
>Then you need the decimal places 1.05, 2.05, 3.05 etc ect
>
>> or having the step size have more decimal places but show fewer
>> in order to deal with round off?
>Again you could use valuFormatFunction.
>
>What might be a better idea is if the class accepted a user defined data
>formatter rather than having dataFormatter as private and in settable.
>
>> Do we know if we're using the right "field" from the globalization
>> classes? Is it a bug in the player we are working around?
>It probably is a bug as it only happens on Windows, I'd assuming it's
>getting the 2 decimal places from the locale currency format and using
>that as the default.
>
>It may also be that this is a bug only shows up in recent Flash Player
>versions on windows.
>
>Thanks,
>Justin
Re: Spark NumericSpinner patch to fix extra digits showing
Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,
> Clever idea. I didn't try it but from looking at this diff, I wonder if
> it is ok to tie the number of decimal places to the step size.
In most cases (that I can think of) it is. It certainly better than what it's currently doing.
> Couldn't there be a difference like stepping by whole dollars but wanting to show
> cents
Can be done by setting the valueFormatFunction.
> maybe starting at some fractional value but stepping by whole
> integers,
Then you need the decimal places 1.05, 2.05, 3.05 etc ect
> or having the step size have more decimal places but show fewer
> in order to deal with round off?
Again you could use valuFormatFunction.
What might be a better idea is if the class accepted a user defined data formatter rather than having dataFormatter as private and in settable.
> Do we know if we're using the right "field" from the globalization
> classes? Is it a bug in the player we are working around?
It probably is a bug as it only happens on Windows, I'd assuming it's getting the 2 decimal places from the locale currency format and using that as the default.
It may also be that this is a bug only shows up in recent Flash Player versions on windows.
Thanks,
Justin
Re: Spark NumericSpinner patch to fix extra digits showing
Posted by Alex Harui <ah...@adobe.com>.
Clever idea. I didn't try it but from looking at this diff, I wonder if
it is ok to tie the number of decimal places to the step size. Couldn't
there be a difference like stepping by whole dollars but wanting to show
cents, or maybe starting at some fractional value but stepping by whole
integers, or having the step size have more decimal places but show fewer
in order to deal with round off?
Do we know if we're using the right "field" from the globalization
classes? Is it a bug in the player we are working around?
Thanks,
-Alex
On 9/11/13 11:24 PM, "Justin Mclean" <ju...@classsoftware.com> wrote:
>Hi,
>
>Someone mind trying out this patch for the spark NumericSpinner?
>
>diff --git
>a/frameworks/projects/spark/src/spark/components/NumericStepper.as
>b/frameworks/projects/spark/src/spark/components/NumericStepper.as
>index 6a45b32..02d0ebf 100644
>--- a/frameworks/projects/spark/src/spark/components/NumericStepper.as
>+++ b/frameworks/projects/spark/src/spark/components/NumericStepper.as
>@@ -796,6 +796,7 @@ public class NumericStepper extends Spinner
> if (dataFormatter == null)
> {
> dataFormatter = new NumberFormatter();
>+ dataFormatter.fractionalDigits = Math.max(0, (stepSize -
>Math.floor(stepSize)).toString().length - 2);
> addStyleClient(dataFormatter);
> }
>
>
>And see if it fixes this issue:
>https://issues.apache.org/jira/browse/FLEX-33657
>
>Thanks,
>Justin