1

In a UITextField used for entering decimal numbers I would like to get rid of possible leading zeros (The behavior should be like the one of the Calculator App). Normally this would be rather easy to implement but I just cannot figure out how to restore the cursor position.

UITextField has a property SelectedTextRange of type UITextRange which can be used to get the cursor position. However, there seems no easy way to get the current index nor to create a new UITextRange object that contains the new values.

I could find the solution in objective c: Finding the cursor position in a UITextField It is however very unclear to me how to rewrite that in Monotouch. Any help with this would be highly appreciated.

Thanks, Manuel

manuel
  • 252
  • 1
  • 9

1 Answers1

1

It looks like MonoTouch (at least the 5.3 alpha I'm looking now) is not exposing every methods in UITextField (and UITextView), in particular those that comes from UITextInput (but the properties are there).

This means that methods like GetPosition are presently missing - which makes it hard to duplicate the code from the link you provided.

UPDATE It was a bug where UITextInput methods were not added to UITextField and UITextView. This will be fixed in the next releases. IOW the next stable release, 5.2.11, will have the missing methods.

poupou
  • 43,413
  • 6
  • 77
  • 174
  • Thanks for your message! Let's hope that they really add it in the next stable version. It cannot be that trivial things like that are not available in Monotouch... – manuel Apr 05 '12 at 02:38