0

I need to capitalize first letter In sentences then user typing string in Edit like I can do it in Eclipse : "android:inputType="textCapSentences"

How can I do it in XE5?

Or may be some other way to change Shift status on virtual keyboard in XE5?

RRUZ
  • 134,889
  • 20
  • 356
  • 483
user2880885
  • 93
  • 2
  • 11

1 Answers1

2

The textCapSentences Corresponds to the TYPE_TEXT_FLAG_CAP_SENTENCES constant which is part of the TextView Android Class. This class is wrapped by the Androidapi.JNI.Widget.JTextView interface but this is not used directly by the Firemonkey TEdit controls, instead Firemonkey uses a proxy class called JFMXTextEditorProxy. so in theory you must access the proxy class linked to the EditControl to set the value TYPE_TEXT_FLAG_CAP_SENTENCES using the setEnterAction method. unfortunately the instance to this proxy class is encapsuled in the TTextServiceAndroid class which is defined in the implementation part of the FMX.Platform.Android unit, so can't be accessed. So the only option which come to my mind is use the OnKeyDown event like :

This will Capitalize the first letter of the EditText and any after a space character.

procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; var KeyChar: Char;
  Shift: TShiftState);
begin
  if  (TEdit(Sender).Text.Length=0) or ((TEdit(Sender).Text.Length>0) and  TEdit(Sender).Text.EndsWith(' ')) then
     KeyChar:=UpCase(KeyChar);
end; 
RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • Yes. I tried that way, but it is not an option for me. I need user to see Capitalized first letter when he typing words, not when hi types " ". May be it is some way to "press" shift in Virtual Keybord? I think it must be. – user2880885 Oct 16 '13 at 00:34