Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSkLabel.TCustomWordsItem OnClick #262

Closed
nemoinkognito opened this issue Sep 7, 2023 · 1 comment
Closed

TSkLabel.TCustomWordsItem OnClick #262

nemoinkognito opened this issue Sep 7, 2023 · 1 comment
Assignees
Milestone

Comments

@nemoinkognito
Copy link

nemoinkognito commented Sep 7, 2023

The TCustomWordsItem OnClick event can trigger sending an out of date argument to the OnClick event handler.
(Skia4Delphi 6.0.0-beta3 on windows, Delphi 11.3)

In my specific example the OnClick handler rebuilds the contents of the SkLabel. If the mouse is clicked again without moving the next OnClick event call will be called with a TCustomWordsItem that is no longer valid. It results in faulty data or an exception. I suspect that FWordsMouseOver is not updated if the mouse does not move.

This solution works for me:
FMX.Skia row 5234

procedure TSkLabel.Click;
var
  LClickedItem: TCustomWordsItem;
begin
  LClickedItem := GetWordsItemAtPosition(FClickedPosition.X, FClickedPosition.Y);
  if Assigned(LClickedItem) and (LClickedItem = GetWordsItemAtPosition(PressedPosition.X, PressedPosition.Y)) then
  begin
    TMessageManager.DefaultManager.SendMessage(Self, TItemClickedMessage.Create(LClickedItem));
    if Assigned(LClickedItem.OnClick) then
      //LClickedItem.OnClick(FWordsMouseOver)
      LClickedItem.OnClick(LClickedItem)
    else
      inherited;
  end
  else
    inherited;
end;
viniciusfbb added a commit that referenced this issue Sep 8, 2023
Co-Authored-By: Paulo César Botelho Barbosa <16469061+paulocesarbot@users.noreply.github.com>
@viniciusfbb viniciusfbb self-assigned this Sep 8, 2023
@viniciusfbb viniciusfbb added this to the vNext milestone Sep 8, 2023
@viniciusfbb
Copy link
Member

viniciusfbb commented Sep 30, 2023

Fixed on new version v6.0.0-beta4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

No branches or pull requests

2 participants