简体   繁体   中英

Flash AS3 DataGrid

I am new to Flash and AS3.

I have a DataGrid like this

Item     Percentage
A        20%
B        7.5%

The percentage column is editable.

It is working atm, but I am just looking to enhance user interaction, so my questions is:

How do you restrict user input to only 0-9, . and %.
And when they finished editing a cell, add "%" if it is not already there.

Thank you in advance :)

To restrict the text that the user can type, you can use the restrict property of the TextInput component. It allows you to provide a string of characters that are allowed in the text input. In this case, your string would be 0-9%. I personally, would also restrict the user from typing % and ALWAYS add it automatically.

To add the % at the end, you could listen for the event when the user changes the text (I believe it's the 'change' event) and if the last character is not "%", append the percent sign to the string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM