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?
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?
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;