mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-15 12:19:13 +02:00
androidlcl: Advances to implementing reading text values
git-svn-id: trunk@32012 -
This commit is contained in:
parent
778c20af82
commit
2338d7ce64
@ -108,6 +108,7 @@ type
|
|||||||
procedure callOnClickListener();
|
procedure callOnClickListener();
|
||||||
public
|
public
|
||||||
procedure setTextSize(unit_: Integer; size: Single);
|
procedure setTextSize(unit_: Integer; size: Single);
|
||||||
|
function getText(): string;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TEditText = class(TTextView)
|
TEditText = class(TTextView)
|
||||||
@ -302,6 +303,7 @@ const
|
|||||||
amkUI_TTextView_OnClickListener_Start = $0010A003;
|
amkUI_TTextView_OnClickListener_Start = $0010A003;
|
||||||
amkUI_TTextView_OnClickListener_Finished = $0010A004;
|
amkUI_TTextView_OnClickListener_Finished = $0010A004;
|
||||||
amkUI_TTextView_setTextSize = $0010A005;
|
amkUI_TTextView_setTextSize = $0010A005;
|
||||||
|
amkUI_TTextView_getText = $0010A006;
|
||||||
// TEditText
|
// TEditText
|
||||||
amkUI_TEditText_Create = $0010B000;
|
amkUI_TEditText_Create = $0010B000;
|
||||||
amkUI_TEditText_setText = $0010B001;
|
amkUI_TEditText_setText = $0010B001;
|
||||||
@ -536,6 +538,14 @@ begin
|
|||||||
vAndroidPipesComm.WaitForReturn();
|
vAndroidPipesComm.WaitForReturn();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TTextView.getText(): string;
|
||||||
|
begin
|
||||||
|
vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
|
||||||
|
vAndroidPipesComm.SendInt(amkUI_TTextView_getText);
|
||||||
|
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
|
||||||
|
Result := vAndroidPipesComm.WaitForStringReturn();
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TEditText.Create();
|
constructor TEditText.Create();
|
||||||
begin
|
begin
|
||||||
vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
|
vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
|
||||||
@ -721,7 +731,6 @@ end;
|
|||||||
|
|
||||||
procedure TArrayAdapter_String_.clear();
|
procedure TArrayAdapter_String_.clear();
|
||||||
begin
|
begin
|
||||||
vAndroidPipesComm.Log(Format('[TArrayAdapter_String_.Clear] Self=%P Index=%X', [@Self, Index]));
|
|
||||||
vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
|
vAndroidPipesComm.SendByte(ShortInt(amkUICommand));
|
||||||
vAndroidPipesComm.SendInt(amkUI_TArrayAdapter_String__clear);
|
vAndroidPipesComm.SendInt(amkUI_TArrayAdapter_String__clear);
|
||||||
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
|
vAndroidPipesComm.SendInt(Index); // Self, Java Pointer
|
||||||
|
@ -18,9 +18,10 @@ uses
|
|||||||
|
|
||||||
const
|
const
|
||||||
// Android Message Kind
|
// Android Message Kind
|
||||||
amkFloatResult = 103;
|
amkStringResult = 14;
|
||||||
amkIntResult = 102;
|
amkFloatResult = 13;
|
||||||
amkResult = 101;
|
amkIntResult = 12;
|
||||||
|
amkResult = 11;
|
||||||
amkActivityCallback = 0;
|
amkActivityCallback = 0;
|
||||||
amkLog = 1;
|
amkLog = 1;
|
||||||
amkUICommand = 2;
|
amkUICommand = 2;
|
||||||
@ -62,6 +63,7 @@ type
|
|||||||
function ReadByte: ShortInt;
|
function ReadByte: ShortInt;
|
||||||
function ReadInt: Integer;
|
function ReadInt: Integer;
|
||||||
function ReadFloat: Single;
|
function ReadFloat: Single;
|
||||||
|
function ReadString: string;
|
||||||
procedure SendMessage(AKind: ShortInt; ASubtype: DWord);
|
procedure SendMessage(AKind: ShortInt; ASubtype: DWord);
|
||||||
procedure SendByte(AData: ShortInt);
|
procedure SendByte(AData: ShortInt);
|
||||||
procedure SendInt(AData: Integer);
|
procedure SendInt(AData: Integer);
|
||||||
@ -70,6 +72,7 @@ type
|
|||||||
procedure WaitForReturn();
|
procedure WaitForReturn();
|
||||||
function WaitForIntReturn(): Integer;
|
function WaitForIntReturn(): Integer;
|
||||||
function WaitForFloatReturn(): Single;
|
function WaitForFloatReturn(): Single;
|
||||||
|
function WaitForStringReturn(): string;
|
||||||
procedure CommError(AStr: string);
|
procedure CommError(AStr: string);
|
||||||
procedure Log(AStr: string);
|
procedure Log(AStr: string);
|
||||||
end;
|
end;
|
||||||
@ -187,6 +190,18 @@ begin
|
|||||||
Move(lNum, Result, 4);
|
Move(lNum, Result, 4);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TAndroidPipesComm.ReadString: string;
|
||||||
|
var
|
||||||
|
lSize, i: Integer;
|
||||||
|
begin
|
||||||
|
Result := '';
|
||||||
|
lSize := ReadInt();
|
||||||
|
for i := 1 to lSize do
|
||||||
|
begin
|
||||||
|
Result := Result + Char(ReadByte());
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TAndroidPipesComm.SendMessage(AKind: ShortInt; ASubtype: DWord);
|
procedure TAndroidPipesComm.SendMessage(AKind: ShortInt; ASubtype: DWord);
|
||||||
begin
|
begin
|
||||||
OutputStream.WriteByte(AKind);
|
OutputStream.WriteByte(AKind);
|
||||||
@ -256,6 +271,16 @@ begin
|
|||||||
Result := ReadFloat();
|
Result := ReadFloat();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TAndroidPipesComm.WaitForStringReturn: string;
|
||||||
|
var
|
||||||
|
lByte: ShortInt;
|
||||||
|
begin
|
||||||
|
{$ifdef ANDROID_NO_COMM}Exit(0.0);{$ENDIF}
|
||||||
|
lByte := ReadByte();
|
||||||
|
if lByte <> amkStringResult then CommError('[TAndroidPipesComm.WaitForStringReturn] expected amkStringResult but got: ' + IntToStr(lByte));
|
||||||
|
Result := ReadString();
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TAndroidPipesComm.CommError(AStr: string);
|
procedure TAndroidPipesComm.CommError(AStr: string);
|
||||||
begin
|
begin
|
||||||
dataString1 := AStr;
|
dataString1 := AStr;
|
||||||
|
@ -60,6 +60,8 @@ type
|
|||||||
params: TAbsoluteLayout_LayoutParams;
|
params: TAbsoluteLayout_LayoutParams;
|
||||||
constructor Create(const AObject: TCustomEdit; const AParams: TCreateParams);
|
constructor Create(const AObject: TCustomEdit; const AParams: TCreateParams);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
function GetText: string;
|
||||||
|
procedure SetText(AText: string);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TAndroidButton }
|
{ TAndroidButton }
|
||||||
@ -405,6 +407,16 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TAndroidEdit.GetText: string;
|
||||||
|
begin
|
||||||
|
Result := edittext.GetText();
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TAndroidEdit.SetText(AText: string);
|
||||||
|
begin
|
||||||
|
edittext.SetText(AText);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TAndroidButton }
|
{ TAndroidButton }
|
||||||
|
|
||||||
constructor TAndroidButton.Create(const AObject: TCustomButton;
|
constructor TAndroidButton.Create(const AObject: TCustomButton;
|
||||||
|
@ -329,10 +329,8 @@ end;
|
|||||||
|
|
||||||
function RegisterCustomMemo: Boolean; alias : 'WSRegisterCustomMemo';
|
function RegisterCustomMemo: Boolean; alias : 'WSRegisterCustomMemo';
|
||||||
begin
|
begin
|
||||||
Result := False;
|
RegisterWSComponent(TCustomMemo, TAndroidWSCustomMemo);
|
||||||
// RegisterWSComponent(TCustomMemo, TGtk2WSCustomMemo, TGtkPrivateScrolling); { GTK1 }
|
Result := True;
|
||||||
// RegisterWSComponent(TCustomMemo, TGtk2WSCustomMemo);
|
|
||||||
// Result := True;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function RegisterButtonControl: Boolean; alias : 'WSRegisterButtonControl';
|
function RegisterButtonControl: Boolean; alias : 'WSRegisterButtonControl';
|
||||||
|
Loading…
Reference in New Issue
Block a user