Lazarus

Programming => Operating Systems => Android => Topic started by: Robert Gilland on June 11, 2019, 06:17:18 am

Title: LAMW jEditText when Done clicked.
Post by: Robert Gilland on June 11, 2019, 06:17:18 am
Hi,

  I cannot get any event to fire when the[ Done] softkeyboard button is pressed.
The demo app isn't firing any event either!
I have looked online for a solution but all solutions use the event "OnEditorAction" which is not available in LAMW!

https://stackoverflow.com/questions/2004344/how-do-i-handle-imeoptions-done-button-click/5369989#5369989

Android 4.2.2 LAMw 0.8 jdk1.8 grade 4

Also why do I keep getting these warnings from Gradle:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.


Title: Re: LAMW jEditText when Done clicked.
Post by: jmpessoa on June 11, 2019, 08:13:03 am

You can get "Done", "Go",  "Next" .... etc....

Handling the "OnEnter" event....

Quote
Also why do I keep getting these warnings from Gradle:
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.

What Gradle do you have? 4.0 ???

LAMW need 4.4.1 or up....

Title: Re: LAMW jEditText when Done clicked.
Post by: Robert Gilland on June 11, 2019, 08:33:47 am
The OnEnter event is not fired where "Done" is pressed on the soft keyboard. That is the issue.



Upgraded Gradle to 5.4. Gradle not issuing warning now.
Title: Re: LAMW jEditText when Done clicked.
Post by: Robert Gilland on June 11, 2019, 04:13:52 pm
Okay I have done my own workaround, I hope it helps someone.

Code: Pascal  [Select][+][-]
  1. unit lamwutils;
  2.  
  3. {$mode delphi}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Laz_And_Controls, AndroidWidget;
  9.  
  10. type
  11.  
  12.   { TjEditTextController }
  13.  
  14.   TjEditTextController = class(TObject)
  15.   private
  16.     fEditText : jEditText;
  17.     fGetStrEvt : TGetStrProc;
  18.     Procedure EditOnChanged(Sender: TObject; txt: string; count: integer);
  19.     Procedure EditOnEnter(Sender: TObject);
  20.   public
  21.     procedure JNIPromptSetup;
  22.     constructor Create( pEditText : jEditText; pGetStrEvt : TGetStrProc );
  23.   end;
  24.  
  25. implementation
  26.  
  27. { TjEditTextController }
  28.  
  29. constructor TjEditTextController.Create( pEditText: jEditText;
  30.   pGetStrEvt: TGetStrProc);
  31. begin
  32.   inherited Create;
  33.   fEditText  := pEditText;
  34.   fGetStrEvt := pGetStrEvt;
  35.   fEditText.OnChanged := EditOnChanged;
  36.   fEditText.OnEnter   := EditOnEnter;
  37. end;
  38.  
  39. procedure TjEditTextController.EditOnChanged(Sender: TObject; txt: string;
  40.   count: integer);
  41. var
  42.   lchar : Char;
  43.   llen  : Integer;
  44. begin
  45.   llen := length( txt );
  46.   if( llen = 0 )then exit;
  47.   lchar := txt[llen];
  48.   if( Ord(lchar) = 10 )then
  49.     fGetStrEvt( Copy(txt,1,llen-1));
  50. end;
  51.  
  52. procedure TjEditTextController.EditOnEnter(Sender: TObject);
  53. begin
  54.   fGetStrEvt( fEditText.Text );
  55. end;
  56.  
  57. procedure TjEditTextController.JNIPromptSetup;
  58. begin
  59.   fEditText.SetImeOptions(imeFlagNoFullScreen);
  60.   fEditText.SetImeOptions(imeActionDone);
  61. end;
  62.  
  63.  
  64.  
  65. end.
  66.  
  67.  
  68.  
Title: Re: LAMW jEditText when Done clicked.
Post by: Robert Gilland on June 12, 2019, 06:56:34 am
Another solution I found was to change the devices keyboard.
TinyPortal © 2005-2018