I need to write a component that will register in its own other components and will detect that one of the registered components receives focus.
For example, for my component, TFocusObserverI register three objects.
FocusObserver.Register(MyMemo);
FocusObserver.Register(MyButton);
FocusObserver.Register(MyEdit);
And now, if one of these components receives focus, then it FocusObserverfires some kind of notification event.
I was looking for how to detect a change in focus, and found that TScreen.OnActiveControlChange- this is exactly what I need. Therefore, my component could connect to this event. The problem is that there may be more than one TFocusObserveror later, in the future, when others may use OnActiveControlChange.
This is the time at which I benefit from the multicast event - it will solve my problem right away.
I was thinking how to solve this, and I currently have two ideas:
- The extension is somehow
TScreen, so it will provide me with another event. - Imagine an intermediate object that connects to
OnActiveControlChangeand outputs one multicast event for other objects.
After a brief look at the sources, I don’t have a clear idea of how to solve this problem using the first idea, and the second idea has the disadvantage that someone can simply assign another method OnActiveControlChange, and the whole filling falls apart.
We will be grateful for some suggestions.
Wodzu source
share