Recent

Author Topic: LAMW jEditText when Done clicked.  (Read 385 times)

Robert Gilland

  • Full Member
  • ***
  • Posts: 146
LAMW jEditText when Done clicked.
« 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.


« Last Edit: June 11, 2019, 07:21:43 am by Robert Gilland »

jmpessoa

  • Hero Member
  • *****
  • Posts: 1435
Re: LAMW jEditText when Done clicked.
« Reply #1 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....

Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Robert Gilland

  • Full Member
  • ***
  • Posts: 146
Re: LAMW jEditText when Done clicked.
« Reply #2 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.
« Last Edit: June 11, 2019, 09:26:51 am by Robert Gilland »

Robert Gilland

  • Full Member
  • ***
  • Posts: 146
Re: LAMW jEditText when Done clicked.
« Reply #3 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.  

Robert Gilland

  • Full Member
  • ***
  • Posts: 146
Re: LAMW jEditText when Done clicked.
« Reply #4 on: June 12, 2019, 06:56:34 am »
Another solution I found was to change the devices keyboard.