[Lazarus] CodeTools On Event insert? detect
I am looking for a way to detect when someone has added an event in the ide, for example button1click.. When someone double clicks a button in lazarus it generates code in the IDE for the event handler procedure.. I want to intercept/detect this, and add SomeCode(); between the begin/end of the event, i.e. on button 1 click. Does codetools provide some way to do it? It has a way to search the source code for a procedure and enter code, but how do you detect when an event is added to the source code? -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org http://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] CodeTools On Event insert? detect
On Wed, 24 May 2017 13:43:10 -0500 Lars via Lazarus wrote: >[...] > I want to intercept/detect this, and add > >SomeCode(); > > between the begin/end of the event, i.e. on button 1 click. > > Does codetools provide some way to do it? Donald Ziesig added templates to alter the inserted code snippets. Please update svn, compile the IDE with -dEnableCodeCompleteTemplates and restart it. Read the header notes in lazarus/components/codetools/codecompletiontemplater.pas Default templates are defined in components/codetools/codecompletiontemplates.xml You can choose your own template file in Tools / Options / Codetools / Code creation / Template file. Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org http://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] CodeTools On Event insert? detect
On 2017-05-26 04:44, Mattias Gaertner via Lazarus wrote: On Wed, 24 May 2017 13:43:10 -0500 Lars via Lazarus wrote: [...] I want to intercept/detect this, and add SomeCode(); between the begin/end of the event, i.e. on button 1 click. Does codetools provide some way to do it? Donald Ziesig added templates to alter the inserted code snippets. Please update svn, compile the IDE with -dEnableCodeCompleteTemplates and restart it. Read the header notes in lazarus/components/codetools/codecompletiontemplater.pas Default templates are defined in components/codetools/codecompletiontemplates.xml You can choose your own template file in Tools / Options / Codetools / Code creation / Template file. Thanks, I will try. Is it a special Define because it is a new untested feature waiting for approval? If so I could be a tester -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org http://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] CodeTools On Event insert? detect
[...] I want to intercept [...] and add SomeCode(); between the begin/end of the event, i.e. on button 1 click. Does codetools provide some way to do it? Found this discussions about it too: http://lists.lazarus.freepascal.org/pipermail/lazarus/2014-March/086457.html http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-RFC-Code-tools-Feature-td4036425.html That's interesting that Michael V. C. wanted logging at begin/end of code snippets in procedures, because that's exactly what powtils had to do but it looks kind of ugly at the source level to have IFDEF DEBUG at the end and begin of each procedure, but that's how I did it.. But, this requirement that I need has nothing to do with that, it's for something else.. but still interesting! -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org http://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] CodeTools On Event insert? detect
On Fri, 26 May 2017 19:52:44 -0500 Lars via Lazarus wrote: >[...] > > Please update svn, compile the IDE with > > -dEnableCodeCompleteTemplates and restart it. >[...] > Thanks, I will try. Is it a special Define because it is a new untested > feature waiting for approval? Yes, and it is waiting for a discussion about the template file. Attributes, format, flexibility. > If so I could be a tester Yes, please. Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org http://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] CodeTools On Event insert? detect
Mattias, I'm still having issues figuring out exactly what Donald Z.'s code does and how to use it, but is there even a way to "hook" the ide event insertion currently? i.e. if you throw a Button on a form and double click it, I want to hook into that, and insert code immediately after the event has been inserted into the ide text edit window.. If this feature is currently not implemented I can work on a patch today that does it, however I don't want to work on a patch if this feature already exists and I just can't find it. Something like: OnAfterEventInsert codetools/lazintf trigger - User adds button 1 to form - user double clicks button 1 - code is inserted inbetween begin/end automatically I think the templates may help this but is there really a hook like this in code tools where you can hook into the events inserted into the IDE when a user double clicks a button/widget or double clicks the event in the object inspector? -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org http://lists.lazarus-ide.org/listinfo/lazarus