13-03-2017, Saat: 10:55
Herkese iyi günler bu problem hakkında bilgisi olan var mıdır?
Aşağıda bulunan kod yardımı ile listemi oluşturup klavyeyi bir defa açtıktan sonra el terminalinden okunan değeri alabiliyorum ancak showmessage sonrası veya TdateEdit gibi nesnelere tıkladıktan sonra tekrar okutma işleminde problem çıkıyor klavyenin tekrar açılıp kapanması gerekiyor bunun ekrana getirmeden gizli bir şekli var mı? yoksa buna ihtiyaç olmadan tekrar okutulan değeri alabilir miyiz
Aşağıda bulunan kod yardımı ile listemi oluşturup klavyeyi bir defa açtıktan sonra el terminalinden okunan değeri alabiliyorum ancak showmessage sonrası veya TdateEdit gibi nesnelere tıkladıktan sonra tekrar okutma işleminde problem çıkıyor klavyenin tekrar açılıp kapanması gerekiyor bunun ekrana getirmeden gizli bir şekli var mı? yoksa buna ihtiyaç olmadan tekrar okutulan değeri alabilir miyiz
procedure TForm1.FormCreate(Sender: TObject); begin if Assigned(FTextListener) then exit; FTextListener := TCustomAndroidTextListener.Create(self); FFMXTxp := FMX.Platform.Android.MainActivity.getTextEditorProxy; FFMXTxp.setInputType(TJFMXTextEditorProxy.JavaClass.INPUT_ALPHABET); FFMXTxp.addTextListener(FTextListener); end; procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState); begin if key = 13 then begin ShowMessage(JCharSequenceToStr(FMX.Platform.Android.MainActivity.getTextEditorProxy.getText)); end; end; procedure UnregisterTextListener; var FFMXTxp: JFMXTextEditorProxy; begin if not Assigned(FTextListener) then exit; FFMXTxp := FMX.Platform.Android.MainActivity.getTextEditorProxy; FFMXTxp.removeTextListener(FTextListener); FTextListener.Free; end; { TCustomTextListener } constructor TCustomAndroidTextListener.Create(aForm: TCommonCustomForm); begin inherited Create; FForm := aForm; end; function TCustomAndroidTextListener.TryAsKey(const aChar: Char; var Key: Word): Boolean; var LOrd: Word; LType: TUnicodeCategory; begin LOrd := 0; LType := System.Character.TCharacter.GetUnicodeCategory(aChar); // lo spazio va calcolato a parte perché è presente un BUG in FForm.KeyDown(LKey, LChar, []); // in quanto il carattere di spazio lo trasforma in #0 impedendone l'invio case LType of TUnicodeCategory.ucControl: begin LOrd := Ord(aChar); if LOrd in [vkReturn, vkLineFeed] then LOrd := vkReturn; end; TUnicodeCategory.ucSpaceSeparator: LOrd := vkSpace; end; Result := LOrd > 0; if Result then Key := LOrd; end; procedure TCustomAndroidTextListener.onComposingText(beginPosition, endPosition: Integer); begin end; procedure TCustomAndroidTextListener.onSkipKeyEvent(event: JKeyEvent); begin end; procedure TCustomAndroidTextListener.onTextUpdated(text: JCharSequence; position: Integer); var LStr: string; LKey: Word; LChar: Char; LPosition: Integer; LValidString: string; begin LStr := JCharSequenceToStr(text); LKey := 0; try // no valid character if position = 0 then exit; // string on mobile are 0 based // the input string contain all characters pressed until this time. So if I pressed f then o then o is something like this "[3]foo" // I have to calculate the last digit character LPosition := 2 + ifthen(position = 0, 1, Trunc(Log10(position) + 1)) + position; LValidString := LStr.Substring(LPosition - position); if FLastStr.Contains(LValidString) and ((FLastStr.Length - LValidString.Length) = 1) then begin // delete command was pressed LChar := #0; LKey := System.UITypes.vkBack; end else LChar := LStr[LPosition - 1]; // I need to understand if the key is not a char but a key to respect the method signature. // See documentation for more details http://docwiki.embarcadero.com/Libraries...rm.KeyDown if TryAsKey(LChar, LKey) then LChar := #0; FForm.KeyDown(LKey, LChar, []); finally FLastStr := LValidString; end; end; procedure TForm1.FormShow(Sender: TObject); begin Edit1.SetFocus; end;