4

In RAD Studio 10.1 Berlin quite a few things has changed from previous version. In FMX there are a few previously published events that has now been changed to only be public.

I have a Multi Platform Project that uses a TStringGrid component and the OnDblClick event. When opening this project in Studio 10.1 I get warned that the Property OnDblClick does not exist.

The question is now how I can use the no longer published event?

(I must say that It's hard to understand why they haven't set mouse events to Published anymore. As far as I know most regular PCs and OSX machines doesn't have touch. A true Multi Target Project should be able to target these systems without hassle as they did in Studio 10 Seattle)

Johan
  • 74,508
  • 24
  • 191
  • 319
TheAviator
  • 41
  • 5
  • 1
    Known bug https://quality.embarcadero.com/browse/RSP-14683 – Sir Rufo Jul 09 '16 at 15:54
  • Ok, I see. The funny thing though is that the Help file reflects the changed state of these event properties. Therefore I thought it was intentional. Or, maybe it was intentional but not really thought thru?? – TheAviator Jul 09 '16 at 17:48
  • The help is created from the source. So this bug is also documented ;o) – Sir Rufo Jul 09 '16 at 18:47

3 Answers3

3

In case the event handlers already exist (which I imply by the error message), you can assign these handlers to their events in FormCreate.

procedure TForm1.FormCreate;
begin
  StringGrid1.OnDblClick := StringGrid1DblClick;
end;
Uwe Raabe
  • 45,288
  • 3
  • 82
  • 130
  • Thank you Uwe! That was exactly what I was looking for. I feel a bit embarrassed for not getting this myself though... – TheAviator Jul 09 '16 at 19:11
2

One solution is to make your own component where you extend the FMX.TStringGrid to have published event handlers again.

See here how to create a new FMX component: creating a firemonkey component

Here's the code to re-publish the mouse events.

unit MyStringGrid;

interface

uses FMX.Grids;

type
  TMyStringGrid = class(TStringGrid)
  published
    property OnDblClick;
    property OnMouseDown;
    property OnMouseMove; 
    property OnMouseUp;
    property OnMouseWheel;
    property OnMouseEnter;
    property OnMouseLeave;
  end;

procedure Register;

implementation

uses FMX.Types;

procedure Register;
begin
  RegisterComponents('NewPage', [TMyStringGrid]);
end;

initialization
  RegisterFmxClasses([TMyStringGrid]);
end.
Community
  • 1
  • 1
Johan
  • 74,508
  • 24
  • 191
  • 319
  • Thank you Johan! This would definitely work but is there any other simpler way to do this? Having to create new components every time a new implementation of a standard component is released by Embarcadero doesn't feel right. – TheAviator Jul 09 '16 at 14:37
2

This has been reported as a bug here.

Looking at the source code in Delphi 10.1 berlin the public OnDblClick event is actually inherited from TControl class.

Similar the OnDblClick event is also inherited from TControl class with the exception that it is made public, like many other events that are inherited from TControl˙ class.

Any way it seems that guys at Embarcadero have been doing some refactoring by cleaning the parent property redeclarations˙(not sure if this is the right term) like:

type
  TParentClass = clas(Tobject)
  public
    property ParentPropery: Integer read GetParentProperty write SetParentProperty;

  TExampleClass = class(TParentClass)
  public
    property ParentPropery;
  end;

Redeclaring ParentProperty in the above case is not needed as it will be available in all child classes unless you want to change its visibility from public to published for instance.

If you look at Delphi 10 Seattle source code you see that property OnDblClick is redeclared in several TStringGrid parent classes being published in TCustomScrollBox for the first time.

Johan
  • 74,508
  • 24
  • 191
  • 319
SilverWarior
  • 7,372
  • 2
  • 16
  • 22