I have an event procedure that checks the OnKeyUp key press for two objects/controls (TNewEdit and TNewComboBox). Both objects need to be completed before a TNewButton gets enabled.
However, I cannot find a way to know how to get the type of the Sender: TObject, if that is TNewEdit or TNewComboBox.
Anyone can help?
You should not need to know the type/class for anything.
Such a need is a sign of a bad design.
If the handling of the event is different for each type/class, create a separate handler for each.
If part of the handling is common, call the common handler from the specific handlers.
Though as you actually have two controls, you probably want to distinguish, what control raised the event.
That's, what the
Senderargument is for. The following code shows how to use it. But again, in general, this is not the right way to go.Though still I do not understand, what you need this for.
You have to check both controls every time, so why do you need to know, what control, was the one that changed?
Also, to detect a change, do not use
OnKeyUp, useOnChange. That way you capture all changes (key press, drag&drop, copy&paste, anything).