Page 1 of 1
Dealing with numbers
Posted: Wed Sep 19, 2012 10:31 pm
by O.R-Dev
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
Re: Dealing with numbers
Posted: Wed Sep 19, 2012 11:20 pm
by dunbarx
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
Re: Dealing with numbers
Posted: Wed Sep 19, 2012 11:48 pm
by dunbarx
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:
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
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:
Code: Select all
on mouseUp
put fld "myField" + 10 into fld "tAnswer"
end mouseUp
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
Re: Dealing with numbers
Posted: Thu Sep 20, 2012 12:35 am
by O.R-Dev
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:
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
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:
Code: Select all
on mouseUp
put fld "myField" + 10 into fld "tAnswer"
end mouseUp
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
Thanks alot guys. I prob should have done a better job of asking my question.
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
Posted: Thu Sep 20, 2012 6:23 pm
by Adrian
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
Re: Dealing with numbers
Posted: Sat Sep 22, 2012 12:15 am
by anmldr
Try using this to set the keyboard to a numeric one that has a decimal
Code: Select all
set iphoneSetKeyboardType "decimal"
or the numeric one
Code: Select all
set iphoneSetKeyboardType "numeric"
Linda