Didier Cabalé 3 Posted April 13, 2021 (edited) Here are the basic steps that show the problem 1. create a VCL project 2. on the TForm's TButton OnClick event, type the following: procedure TForm1.Button1Click(Sender: TObject); var lMyObject: TMyObject; begin lMyObject := TMyObject.Create; lMyObject.DoIt; end; 3. select the 'DoIt', and type Ctrl+Alt+M to invoke adding a method for (obviously) TMyObject 4. state that the Add method form proposes a method adding for the TForm1, instead of for TMyObject I actually wanted to get some other's feedbacks, before sending this to MMX support Edited April 13, 2021 by Didier Cabalé Share this post Link to post
Uwe Raabe 2064 Posted April 13, 2021 2 hours ago, Didier Cabalé said: adding a method for (obviously) TMyObject Wrong Expectation! The method is (obviously) added to the currently selected object TForm1. Works as expected. Share this post Link to post
Didier Cabalé 3 Posted April 13, 2021 4 hours ago, Didier Cabalé said: lMyObject.DoIt; 1. But DoIt is obviously a TMyObject method, not a TForm one. 2. If you stick on your point, then how do you add a TMyObject method on the fly? Share this post Link to post
Bill Meyer 337 Posted April 13, 2021 5 minutes ago, Didier Cabalé said: 1. But DoIt is obviously a TMyObject method, not a TForm one. 2. If you stick on your point, then how do you add a TMyObject method on the fly? You put your cursor in the TMyObject class, and then use Ctrl + Alt + M. Share this post Link to post
Didier Cabalé 3 Posted April 13, 2021 1. I understand now the logic. 2. However, this logic does not fit to the use-case I quoted. -> MMX could add an option of which class the method must be added to. Thanks for your replies! Share this post Link to post
Bill Meyer 337 Posted April 13, 2021 45 minutes ago, Didier Cabalé said: 1. I understand now the logic. 2. However, this logic does not fit to the use-case I quoted. -> MMX could add an option of which class the method must be added to. Thanks for your replies! Alternately, you might recognize that the use case you cited is not supported. Share this post Link to post
Uwe Raabe 2064 Posted April 13, 2021 2 hours ago, Didier Cabalé said: MMX could add an option of which class the method must be added to. Adding a layer of action to achieve a goal is probably not well accepted by long time MMX users as it would break their work flow. Even if such functionality would exist, which class should the method be added when DoIt is not declared in TMyObject, but in TMyBaseObject, which TMyObject is derived from? Instead of asking for the target object each time, it is much simpler to Ctrl-Click on the TMyObject reference or even the DoIt reference in the code, which immediately selects the requested object on which the Add Method action then can be executed on. 2 Share this post Link to post
Didier Cabalé 3 Posted April 14, 2021 15 hours ago, Uwe Raabe said: Adding a layer of action to achieve a goal is probably not well accepted by long time MMX users as it would break their work flow. I totally agree. 15 hours ago, Uwe Raabe said: Even if such functionality would exist, which class should the method be added when DoIt is not declared in TMyObject, but in TMyBaseObject, which TMyObject is derived from? The same question does exist when you propose to add a method to TForm1. And in that case, you simply add it to TForm1, not to TForm, the TForm1 ancestor. 15 hours ago, Uwe Raabe said: Instead of asking for the target object each time, it is much simpler to Ctrl-Click on the TMyObject reference or even the DoIt reference in the code, which immediately selects the requested object on which the Add Method action then can be executed on. 1. Ctrl-Click on the TMyObject, that selects TMyObject, makes you loose the fluidity of the change (helped with bookmark #7 and bookmark #9 when method added to TForm1) 2. Ctrl-Click on DoIt does not do anything, because it is not created yet. Share this post Link to post
Uwe Raabe 2064 Posted April 14, 2021 1 hour ago, Didier Cabalé said: Ctrl-Click on DoIt does not do anything, because it is not created yet. OK, I didn't realize that DoIt doesn't exist. MMX basically works on the current unit and the selected entity - property, method, class, module etc. Share this post Link to post