As TLama pointed out, the new identifier has to be registered in both ScriptClasses_C.pas
and ScriptClasses_R.pas
. To be a little more specific in matters of the question:
In ScriptClasses_C.pas
I created a procedure RegisterTNewButton_C
to let the compiler know about my new identifier for the button:
procedure RegisterTNewButton_C(Cl: TPSPascalCompiler);
begin
with Cl.AddClassN(Cl.FindClass('TButton'), 'TNewButton') do
begin
RegisterProperty('NoShortcut', 'Boolean', iptrw);
end;
end;
In ScriptClasses_R.pas
I basically do the same, but I additionally had to implement to getter and setter for the new identifier:
procedure TNewButtonNoShortcut_R(Self: TNewButton; var T: Boolean);
begin
T := Self.NoShortcut;
end;
procedure TNewButtonNoShortcut_W(Self: TNewButton; const T: Boolean);
begin
Self.NoShortcut := T;
end;
procedure RegisterTNewButton_R(CL: TPSRuntimeClassImporter);
begin
with CL.Add(TNewButton) do
begin
RegisterPropertyHelper(@TNewButtonNoShortcut_R,@TNewButtonNoShortcut_W,'NoShortcut');
end;
end;
To make it finally work RegisterTNewButton_C
has to be called in the method ScriptClassesLibraryRegister_C
and RegisterTNewButton_R
in ScriptClassesLibraryRegister_R
accordingly.
In addition I deleted/commented the lines that registered TNewButton previously (in RegisterBidiCtrls_C
and in RegisterBidiCtrls_R
) to avoid errors that could evolve when a component is registered twice. But I don't know if this is necessary.