Subsequently to this thread
https://forum.lazarus.freepascal.org/index.php/topic,54099.0.html-- transferring some code from the main form to other pas files that won't ccompil:
Doing within the construcor of "MyCustomListview" or shortly after the constructor has been finished:
OnDropFiles := DoOnDropFiles; // Won't compile! : "identifier not found : OnDropFiles"
It turns out that "OnDropFiles" is not a property of the custom listview (as i, for a short moment, did assume), but a property of Application, through which the dropiing is routed.
By that i get it back to work:
// "DoOnDropFiles" is a method of my custom listview class
Application.OnDropFiles := DoOnDropFiles; // does work
My
question #1 is: is the conceptually ok to do so?
But: by that, an invocation of the callback won't be bound any longer to the instance. but to the class.
This does lead to
question #2.
Assuming i have two instances of the class in speech opened on the form. And assuming i did for both (hard-coded for the moment in the main form, what i'm in fact won't like to do) a "DragAcceptFiles(<componentname>,. true)":
If i drop a file from outside of the app onto
listview_1. the callback DoOnDropFiles will be triggered for listview_1 ... and as well for listview_2 (as it's class related) - understandable -, allthough the drop did happen only onto listview_1.
Is this by concept or by my own false thinking; and howto assure that only listview_1 is the processed drop target? Does it need (from the perspective of a component) eg. to inquire if it has the focus before it starts to do something or not? I'd like to try to avoid as less as possible coding about that in the main form.
The mai form should not necessary the instance or class names of such objects (encapsulation).