MagicFoundation / Alcinoe

Alcinoe Component Library For Delphi. Full opengl video player, WebRTC delphi wrapper, native ios/android TEdit, Improuved firemonkey controls, Firebase cloud messaging, Android/ios facebook sdk login, Json/Bson Parser, ImageMagick wrapper, MongoDb client And much more
Apache License 2.0
998 stars 220 forks source link

Problem with TEdit with Alcinoe #318

Closed gonzzzales closed 9 months ago

gonzzzales commented 9 months ago

Hi I found a problem with TEdit and TALEdit when using Alcinoe in D12. Make new application, then put TEdit on form. In project options write in Search Path "D:\Alcinoe-master\Embarcadero\Athens\fmx" After that it is impossible to select all the text in TEdit with mouse. First char is not selectable. Also i can not set cursor on first char. The TALEdit has the same behavior.

gonzzzales commented 9 months ago

@Zeus64, please tell me what can be done about it.

Zeus64 commented 9 months ago

@gonzzzales do you see the bug on windows or on android/ios ? with version of delphi do you use ? can you reproduce this bug in the https://github.com/MagicFoundation/Alcinoe/tree/master/Demos/ALFmxControls/_Source demo ?

gonzzzales commented 9 months ago

This bug i see on Windows. Delphi Version is 12. In demo project this is especially noticeable, it is almost impossible to highlight the text in the edit field regardless of whether it's TEdit or TALEdit

gonzzzales commented 9 months ago

@Zeus64, sorry to interrupt, is there any hope that the problem can be solved?

Zeus64 commented 9 months ago

@gonzzzales can you update the Alcinoe repository, launch again the update.bat located in https://github.com/MagicFoundation/Alcinoe/blob/master/Embarcadero/Athens/Update.bat and say me if everything work fine now ?

gonzzzales commented 9 months ago

Unfortunately, I didn't notice any changes. Am i right, you change only Athens.patch, and al othe files are the same? I can make a movie with this behavior

Zeus64 commented 9 months ago

@gonzzzales yes i changed the Athens.patch, can you look in Alcinoe\Embarcadero\Athens\fmx\FMX.Canvas.D2D.pas if you have :

//https://quality.embarcadero.com/browse/RSP-39734
if TrailingHit then Inc(Result); // HitTestMetrics.textPosition look like zero based
//if TrailingHit then
//  Result := Result + Integer(HitTestMetrics.length);

please copy this part of your Alcinoe\Embarcadero\Athens\fmx\FMX.Canvas.D2D.pas here

gonzzzales commented 9 months ago

Hmm, i think patch not worked propertly, or i did something wrong. I have this in CanvasD2D.pas

` function TTextLayoutD2D.DoPositionAtPoint(const APoint: TPointF): Integer; var TrailingHit: BOOL; Inside: BOOL; HitTestMetrics: TDWriteHitTestMetrics; LRect: TRectF; HitTestPoint: TPointF; begin Result := -1; if FLayout = nil then Exit;

LRect := Self.TextRect; LRect.Width := Max(LRect.Width, MaxSize.X); if IsPointInRect(APoint, LRect) then begin HitTestPoint := APoint - TopLeft - TPointF.Create(Padding.Left, Padding.Top); FLayout.HitTestPoint(HitTestPoint.X, HitTestPoint.Y, TrailingHit, Inside, HitTestMetrics); Result := HitTestMetrics.textPosition; //https://quality.embarcadero.com/browse/RSP-39734 if Result >= 0 then Inc(Result); // HitTestMetrics.textPosition look like zero based //if TrailingHit then // Result := Result + Integer(HitTestMetrics.length); end else if ((APoint.X < LRect.Left) or SameValue(APoint.X, LRect.Left, TEpsilon.Position)) and ((APoint.Y > LRect.Top) or SameValue(APoint.Y, LRect.Top, TEpsilon.Position)) and ((APoint.Y < LRect.Bottom) or SameValue(APoint.Y, LRect.Bottom, TEpsilon.Position)) then Result := 0; if (Result >= 0) and (Result < Text.Length) and Text.Chars[Result].IsLowSurrogate then Inc(Result); end; `

gonzzzales commented 9 months ago

I made your changes manually, and it work fine Thank you very much!!!!

Zeus64 commented 9 months ago

perfect! i guess you didn't update your repository or you forgot to run update.bat located in https://github.com/MagicFoundation/Alcinoe/blob/master/Embarcadero/Athens/Update.bat. Happy that it's work now for you