Dealing with numbers
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Dealing with numbers
Hi guys. Im creating a tool for operations research (early stages).
2 issues have put a complete stop to my work. I was wondering if anyone knew how to bring up only the numeric keypad for a text entry field.
and secondly how to make calculations using the number in that field with other numbers in other fields.
any help would be greatly appreciated
2 issues have put a complete stop to my work. I was wondering if anyone knew how to bring up only the numeric keypad for a text entry field.
and secondly how to make calculations using the number in that field with other numbers in other fields.
any help would be greatly appreciated
Re: Dealing with numbers
Hi.
Do you mean you want to lock out the ability of the user to use the numeric keys overlying the standard keyboard?
Check out the "rawKeyUp" message. You can trap this, and the parameter passed is different for the keys in the numeric keypad as opposed to the keys above the ordinary keypad.
As for doing calculations, nothing could be simpler. And by that I mean that it will be an adventure filled with both peril and triumph.
How experienced are you? Write back if you need examples of either of the things I mentioned.
Craig Newman
Do you mean you want to lock out the ability of the user to use the numeric keys overlying the standard keyboard?
Check out the "rawKeyUp" message. You can trap this, and the parameter passed is different for the keys in the numeric keypad as opposed to the keys above the ordinary keypad.
As for doing calculations, nothing could be simpler. And by that I mean that it will be an adventure filled with both peril and triumph.
How experienced are you? Write back if you need examples of either of the things I mentioned.
Craig Newman
Re: Dealing with numbers
It occurs to me you already could use examples, or you would not have phrased your query the way you did.
In a new stack, make a field. Name this "myField". Place the following handler in the card script:
Now you must examine this. What is going on? And how can I figure out a way to handle all the digits? Is there a more compact way to manage the keyCodes?
In your stack, make another field. Name this "tAnswer". Make a button. Name this "calc". In the button script:
You can, at least at this point, be able to load 6's and 7's into field "myField". When you press the button, you add 10 to that value, and place the sum in field "tResult"
Now get going, and make this all work. Write back at any time for more help. Really. Anytime.
Craig Newman
In a new stack, make a field. Name this "myField". Place the following handler in the card script:
Code: Select all
on rawKeyUp var
switch var
case 65432 --keyCode for "6"
put "6" after fld "myField"
break
case 65429 --keyCode for "7"
put "7" after fld "myField"
break
end switch
end rawKeyUp
on keyDown
end keyDown
In your stack, make another field. Name this "tAnswer". Make a button. Name this "calc". In the button script:
Code: Select all
on mouseUp
put fld "myField" + 10 into fld "tAnswer"
end mouseUp
Now get going, and make this all work. Write back at any time for more help. Really. Anytime.
Craig Newman
Re: Dealing with numbers
Thanks alot guys. I prob should have done a better job of asking my question.dunbarx wrote:It occurs to me you already could use examples, or you would not have phrased your query the way you did.
In a new stack, make a field. Name this "myField". Place the following handler in the card script:Now you must examine this. What is going on? And how can I figure out a way to handle all the digits? Is there a more compact way to manage the keyCodes?Code: Select all
on rawKeyUp var switch var case 65432 --keyCode for "6" put "6" after fld "myField" break case 65429 --keyCode for "7" put "7" after fld "myField" break end switch end rawKeyUp on keyDown end keyDown
In your stack, make another field. Name this "tAnswer". Make a button. Name this "calc". In the button script:You can, at least at this point, be able to load 6's and 7's into field "myField". When you press the button, you add 10 to that value, and place the sum in field "tResult"Code: Select all
on mouseUp put fld "myField" + 10 into fld "tAnswer" end mouseUp
Now get going, and make this all work. Write back at any time for more help. Really. Anytime.
Craig Newman
i figured how to use the data in fields to do calculations using different forms of this exampe
on mouseUp
put field "s11" + field "s21" + field "s31" into field "total"
it works fine on the iphone simulator. However when the user in inputting the data the regular keyboard pops up . The user then has to switch to numbers. I would to make the default numpad to pop up instead of the keypad because there is no use for letters in the application .
Re: Dealing with numbers
If you make your fields iOS native ones (which means creating them via script), then you can define the default keyboard using keyboardType. See the LiveCode iOS Relelase Notes for details (under "Inut control - UITextField").
Cheers,
Adrian
Cheers,
Adrian
Re: Dealing with numbers
Try using this to set the keyboard to a numeric one that has a decimal
or the numeric one
Linda
Code: Select all
set iphoneSetKeyboardType "decimal"
Code: Select all
set iphoneSetKeyboardType "numeric"