If not Mode Delphi!
result[i].onclick:=@refTextClick.onclick;
If the current suggestions not work, I would suggest that...
Error: Wrong number of parameters specified for call to "refTextClick"
Can someone explain what I should be doing?...you explain by showing your "OnClick" event header/signature.
Error: Wrong number of parameters specified for call to "refTextClick"
...you explain by showing your "OnClick" event header/signature.
That is not an event and also not what you showed in your first post. see: https://wiki.freepascal.org/Form_Tutorial#Creating_a_new_form_dynamicallyHow does that explain what syntax I need? I'm trying to assign a event procedure to an event , not define a new one.
procedure refTextClick(Sender: TObject);
If refTextClick.OnClick is already an existing method from an existing instance (a procedure of object and assuming refTextClick is a TStaticText) the initial code should work. It is perfectly allowed to share a method between classes/components, but they should be there.
A method has a hidden self parameter. You can't simply assign a normal procedure to an event. That needs to be a method, a.k.a. procedure of object.
That is exactly what I'm doing. Maybe I did not post enough context with that declaration:That is at least much better and yes that is how it is suppose to look.
TPuzzleForm = class(TForm) procedure refTextClick(Sender: TObject); private .....
So I seem to be doing what you say should work but it gets rejected by the compiler. Maybe I'm still missing, or mis-explaining, something.
*snip*
That is exactly what I'm doing. Maybe I did not post enough context with that declaration:
TPuzzleForm = class(TForm) procedure refTextClick(Sender: TObject); private .....
So I seem to be doing what you say should work but it gets rejected by the compiler. Maybe I'm still missing, or mis-explaining, something.
How does that explain what syntax I need? I'm trying to assign a event procedure to an event , not define a new one.Since you get an error, I asked, I am sorry that it made you sad that I asked.
Since you get an error, I asked, I am sorry that it made you sad that I asked.Where did I say I was "sad".
Hmm...
result[i].onclick:=refTextClick.onclick;
since refText.onclic is refTextClick , I still don't see why it failed doing it that way.Double hmmm....
CompB.OnClick := @refTextClick; // Depending on the mode you may not need the @
lbl.OnClick := @GenericOnClick;
Your rather annoying way of refusing to answer the question and making it ten times harder to understand does not help. I'm sure you are playing some kind of "teacher" game but it does not work. Reconsider the "educational theory" you think you learnt somewhere....good luck, I just tried to help and put even a full working example here.
Thanks alpine. This works:
result[i].onclick:=refText.onclick;
since refText.onclick is refTextClick , I still don't see why it failed doing it that way.
Because you wrote refTextClick.onclick (in your first post).Ah , indeed. And so did the first two replies which is why that did not work either !
QuoteBecause you wrote refTextClick.onclick (in your first post).Ah , indeed. And so did the first two replies which is why that did not work either !
Anyway, as I posted in my previous reply to alpine, this is now working. Thanks to all for replies.
since you didn't show declaration they couldn't know that your component name was refText and not refTextClick.well they couldn't know that refTextClick was not an integer variable either , but no one assumed that. I did show the create() call of the dynamics and stated that the other variable was of the same type. There was no ambiguity.
Error: Wrong number of parameters specified for call to "refTextClick"