AutoCreate Properties lazarus / 9-Editor ---------------------------------------------------------------------- JimKueneman · 2013-11-29 16:13 Not that it was popular but I use to use CodeFactor to write Delphi code.  What it could do is if I was writing code in a method and I needed a new property I could just use it in the method, hilight it and then hit create property, it would show a dialog where I could enter the type, if it has setters/getters, allow me to change the names of the setters/getters if I wanted, and if it was public/private/protected.... once I hit ok the new property was created and I could keep on working within the method.  Is there a similar feature in Lazarus or one of its addins? Thanks, Jim ---------------------------------------------------------------------- typo · 2013-11-29 16:18 An interesting idea that developers should examine. BugTracker? Some sort of code completion, I guess. SynEdit perhaps. ---------------------------------------------------------------------- Martin_fr · 2013-11-29 18:41 Well that is codetool stuff. Something similar exists, but not for property. Install package "Cody" There is "Declare Variable" It just needs to be extended to offer property. ---------------------------------------------------------------------- CaptBill · 2013-11-29 21:51 Quote from: typo on November 29, 2013, 05:18:18 pmAn interesting idea that developers should examine. BugTracker? Some sort of code completion, I guess. SynEdit perhaps. It would be awesome if the SynEdit had a simple interface to monitor for keywords. It would be nice to be able to type in a variable in a class definition and have an alt+key pop up a form to set up the accessor method/s, set scoping etc. What would be the simplest approach to this? I can understand catching the onChange event of SynEdit and calling a custom modal form but am clueless of the right way to insert the code into the SynEdit, mainly because one needs to know CodeTools well it seems. What is the best approach concerning CodeTools? I got lost quick attempting to grasp CodeTools haha. Don't suppose there is a newbie tutorial for CodeTools I missed by chance? Hahaha But seriously, this would be an awesome addition to the SynEdit component, which is already without equal that I am aware of. I do think the discussion belongs right here in the 'wish list' discussion, and not on the wiki or bug tracker. ---------------------------------------------------------------------- Martin_fr · 2013-11-29 22:01 @CaptBill: There are a lot of thinks there already. http://wiki.lazarus.freepascal.org/Lazarus_IDE_Tools#Identifier_Comple tion http://wiki.lazarus.freepascal.org/Lazarus_IDE_Tools#Code_Completion If you are in the declaration you can very quickly write a new property. However if you are in the method body (as JimKueneman was asking), then there only are ways to create variables (local, global, fields), but not properties. So my guess is (I do not know code tool internals) that when you look at "declare variable" from cody, it will not be to much to add properties there too. ---------------------------------------------------------------------- CaptBill · 2013-11-30 09:07 Thanks Marten, The CodeTools are definitely impressive to behold. Unfortunately, they would only be used by the more advanced users. If  a simple key combo would pop up a custom form (and in-place like the drop-down lists currently) to, for example, aid in designing the accessor method/function would be a great addition to us guys who have not yet crested the OOP learning curve yet. That will involve a more complex ability to do compound operations with CodeTools. Defining accessors should be a rather simple affair. But what about being able to define data aware properties where you need to create six related procedures and two functions? Code: [Select]  TMyClass = class(TComponent)     private       { Private fields of TMyClass }         FDataLink : TFieldDataLink;       { Private methods of TMyClass }         { Method to set variable and property values and create objects }         procedure AutoInitialize;         { Method to free any objects created by AutoInitialize }         procedure AutoDestroy;         { Read method for property DataField }         function GetDataField : String;         { Write method for property DataField }         procedure SetDataField(Value : String);         { Read method for property DataSource }         function GetDataSource : TDataSource;         { Write method for property DataSource }         procedure SetDataSource(Value : TDataSource);         procedure ActiveChange(Sender : TObject);         procedure DataChange(Sender : TObject);         procedure EditingChange(Sender : TObject);         procedure UpdateData(Sender : TObject); Wouldn't it be a good idea to have these often used "mechanisms" produced from a templated code source anyway? This will necessitate lots of forethought/discussion, I would think...and from both pros and novices alike. Us novices will benefit by the ability to do more advanced things more intuitively and you pros will have a new high gear for RAD programming. Plus it could lead us into some other nice possibilities like "Imperative drawing". Imagine being able to design "imperatively" with BGRAbitmap and utilize the customdrawn features to produce the paint procedure for your classes/components, and in-place within the SynEdit. I think this would help us all by keeping the focus upon the code where it belongs, pulling the "IDE" closer to what we need to be focused on...the code itself. Go to 1:48 seconds and see Qt5 doing "imperative drawing". http://youtu.be/vhWS_bN-T3k ---------------------------------------------------------------------- Martin_fr · 2013-11-30 09:30 Well new ideas are always welcome. But many will only make it, if there are new contributors too. Unlike the QT developers, who are paid for doing that, and can spent 5 full days a week per person, we do this in our free time. (That is a few evenings a week). New tools, alone will not necessary make it better. It is one more keycombo to learn, and many will never know it is there. I do not know, if your accessors are that a common case for that many people. But you already can define your own templates: http://wiki.lazarus.freepascal.org/Lazarus_IDE_Tools#Code_Templates If those procedures are events, that you assign to some other object, then the answer was in the las post: http://wiki.lazarus.freepascal.or g/Lazarus_IDE_Tools#Event_Assignment_Completion If those are property accessors, and you do have the propety, they are created, if you do class completion. Code: [Select]type TFoo= class   property Bar: Integer read GetBar write SetBar; end; Shift-Ctrl-C I suggest to read the entire page. And this one too: http://wiki.lazarus.freepascal.org/New_IDE_features_since Remember the features, not the keystrokes. And when you need it, then look up the keys. ---------------------------------------------------------------------- Edson · 2013-11-30 16:13 I think, some solution could be for make the IDE more interactive. I really miss the code-completion of VB6, when declaring variables. You just type "myvar as", for default, a pop-up list appear on the screen for different types, without  nothing about Ctrl+Shift+???. Lazarus have very powerfull tools for code. But many people doesn't realize (included me). If for example we can make (for default) than the completion list could suggest templates or code (according to the context) since the first letter pressed, with no need for Shift+Ctrl+???. It will be a way for show the powerfull features of Lazarus. Well. It's just a suggestion. ---------------------------------------------------------------------- CaptBill · 2013-11-30 20:37 QuoteWell new ideas are always welcome. But many will only make it, if there are new contributors too. Unlike the QT developers, who are paid for doing that, and can spent 5 full days a week per person, we do this in our free time. (That is a few evenings a week). Oh, I was only suggesting some discussion on the subject and maybe suggestions on what a simple interface might look like to CodeTools for such features. I totally understand the main developer have their plates full with only I can imagine. The concept is simple and should be approachable for even a novice if there were a simple interface or something of that nature to CodeTools for this. Plus, there just isn't much training/tutorials to help beginners to OOP. If there were a tool that would serve as 'training wheels' for those new to OOP it would help immensely with the steep learning curve, and hopefully, attract more would-be contributors. Plus, I would only want to proceed with something if I felt the team was cool with the concept to begin with. Unfortunately it seems to be a taboo subject matter. ---------------------------------------------------------------------- Martin_fr · 2013-12-03 15:06 Suggestions are fine. I did not mean to undermine that. I just thought I point out what is already there. Simply because that can be used today, while a suggested feature may be available only in some month or years. Also, if no one on the forum says they will be looking into it, then no one does. I don't work on codetools, so I will not look into it. If there is a *detailed* description, and *enough* people want it. Then it can be risen as feature request on mantis. That does not guarantee anything, but that all relevant developers will be aware of it then, and it wont be forgotten. But Mantis is not for discussion. You firs need a detailed exact definition.