Copy link to clipboard
Copied
Help please!
I hope you can save me on this one:
How can I actually change the Numeric Stepper value by entering a number via keyboard without having to press enter or click another Numeric Stepper?
I've tried everything, including keyboard events, but had no success.
All I want is, as soon as I type a number, the numeric stepper value changes to it.
Any ideas?
Thank you so much!
I anticipated you wanting more than you described, but you need to make sure your stepper has a maximum sufficient to handle the values you might expect to enter.
stage.addEventListener(KeyboardEvent.KEY_UP, keyUsed);
var numBuilder:String = "";
function keyUsed(event:KeyboardEvent)
{
if(event.charCode >= 48 && event.charCode <= 57){
numBuilder += String(event.charCode - 48);
stepper.value = Number(numBuilder);
} else {
numBuilder = "";
}
}
As far as managing different steppers with the sa
...Copy link to clipboard
Copied
Here's one way...
stage.addEventListener(KeyboardEvent.KEY_UP, keyUsed);
function keyUsed(event:KeyboardEvent)
{
if(event.charCode >= 48 && event.charCode <= 57){
stepper.value = event.charCode - 48;
}
}
Copy link to clipboard
Copied
Thanks a lot Ned!
Unfortunaly, it only works correctly if the value is less than 10, since it only captures the last KeyboardEvent. Plus, since I have more than one Numeric Stepper, it would change all of them at the same time (although I could look for which one is on focus.. hum.. and maybe only then capture the keys into a string... I could try that).
Thanks a lot for the pointers!
Copy link to clipboard
Copied
I anticipated you wanting more than you described, but you need to make sure your stepper has a maximum sufficient to handle the values you might expect to enter.
stage.addEventListener(KeyboardEvent.KEY_UP, keyUsed);
var numBuilder:String = "";
function keyUsed(event:KeyboardEvent)
{
if(event.charCode >= 48 && event.charCode <= 57){
numBuilder += String(event.charCode - 48);
stepper.value = Number(numBuilder);
} else {
numBuilder = "";
}
}
As far as managing different steppers with the same code goes... good luck. I don't think Flash has the ability to read minds yet and determine which stepper you are thinking of when a key is pressed. Anyway, you have a solution for what you initially asked for.
Copy link to clipboard
Copied
Thanks a lot for your help. I have actually dismissed the numeric stepper component and made my own, using buttons and text field. It worked better for me.
Again, thanks for your help and code!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more