Recent

Author Topic: Subclass existing visual control ?  (Read 363 times)

jsuzineau

  • Newbie
  • Posts: 3
Subclass existing visual control ?
« on: June 09, 2022, 04:31:00 pm »
Hello,
Is it possible to subclass an existing LAMW Visual Control ?
For example something like :
Code: Pascal  [Select][+][-]
  1. type
  2.   TSomething = class(jEditText)
  3.   // Propriété Field
  4.   private
  5.     FField: String;
  6.   published
  7.     property Field: String read FField write FField;
  8.   end;
  9.  

After creating such kind of component, I can rebuild Lazarus .
But when I hit F12 to show a form which uses this component, Lazarus freezes.
And if I try to build the project, I get an an error on linking.

I also tried to copy and paste the whole code of jEditText (duplicating and modifying jEditText.create, jEditText.native, jEditText.java) but I got the same behaviour.

I didn't got this kind of problem when I added another component for android.media.AudioTrack.

My main goal is to make a LAMW version based on JEditText of a "desktop" control based on TEdit for my ORM.
I've already made an attempt in 2017, but I'm not sure it was working, and LAMW has changed since.

lamw version: https://github.com/jsuzineau/pascal_o_r_mapping/blob/TjsDataContexte/pascal_o_r_mapping/09_Controls_LAMW/ucjChamp_Edit.pas
desktop version:  https://github.com/jsuzineau/pascal_o_r_mapping/blob/TjsDataContexte/pascal_o_r_mapping/05_Controls/ucChamp_Edit.pas

jmpessoa

  • Hero Member
  • *****
  • Posts: 2149
Re: Subclass existing visual control ?
« Reply #1 on: June 09, 2022, 11:33:40 pm »
Quote
Is it possible to subclass an existing LAMW Visual Control ?

not so easily .... but you can easily create your new component!
« Last Edit: June 10, 2022, 01:47:41 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

jsuzineau

  • Newbie
  • Posts: 3
Re: Subclass existing visual control ?
« Reply #2 on: June 10, 2022, 08:25:09 am »
Thank you very much for the answer.

So I've made a handler component which connects to jEditText "from the outside", it works:
Code: Pascal  [Select][+][-]
  1.  ThSomething
  2.  =
  3.   class( TComponent)
  4.   //EditText
  5.   private
  6.     Fet: jEditText;
  7.     procedure Setet( _Value: jEditText);
  8.   published
  9.     property et: jEditText read Fet write Setet;
  10.  // Propriété Field
  11.   private
  12.     FField: String;
  13.   published
  14.     property Field: String read FField write FField;
  15.   end;
  16.  

 

TinyPortal © 2005-2018