cocoa-touchuikeyboardnumpad

XCode : Number pad with point for comma


I have a number pad with done button. But the user can only choose numbers without commas. Is there a way to have a number pad with donebutton (which I have), integrated with punctuation, or at least a point for the comma?


Solution

  • Your question implies that you're doing to be doing some formatted number. It would then seem like a safe assumption that you're going to be working with a fixed number of decimal places (as it is more common to see a formatted number with a fixed number of decimal places than without).

    If this is true, then you don't need the . or , buttons at all. You could just start with the fixed number of decimal places and shift stuff over. For example, let's say you want to type the number "4,238.07".

    ______.__  //type 4
    ______._4  //type 2
    ______.42  //type 3
    _____4.23  //type 8
    ____42.38  //type 0
    ___423.80  //type 7
    _4,238.07