Code Tools tuning - location of new events
Original Reporter info from Mantis: ggeldenhuys
-
Reporter name: Graeme Geldenhuys
Original Reporter info from Mantis: ggeldenhuys
- Reporter name: Graeme Geldenhuys
Description:
At the moment the events are always added to the first published section. There is currently no way to tell Code Tools where to place new event handlers.
Maybe Code Tools can have a new tuning option as follows: Specify the preferred location for new event handlers: first published, public, protected, private, ask. "Ask" will popup a dialog.
Maybe the option could be called: "Event insert policy" to keep with the naming convention used for other similar policies. A radio button group will then contain the options listed above.
Below is the message I posted to the mailing list explaining the issue in more details.
==========[ forward ]==============
I have code defined as follows (it's a fpGUI Toolkit project). Here I
have a Form with 2 Buttons on it. No event handlers have been defined yet.
TMainForm = class(TfpgForm)
private
{@VFD_HEAD_BEGIN: MainForm}
btnCreate: TfpgButton;
btnDebug: TfpgButton;
{@VFD_HEAD_END: MainForm}
public
procedure AfterCreate; override;
end;
Inside the AfterCreate() method is the code that initializes the GUI.
fpGUI doesn't use external *.lfm files like Lazarus LCL projects.
Anyway, I add a OnClick event handler in the AfterCreate method for one
of the buttons.
btnDebug := TfpgButton.Create(self);
with btnDebug do
begin
...
OnClick := | // | is the cursor position
end;
I then press Ctrl+Shift+C to fire off code completion which creates the
event handler. This is the result:
TMainForm = class(TfpgForm)
procedure btnDebugClick(Sender: TObject);
private
{@VFD_HEAD_BEGIN: MainForm}
btnCreate: TfpgButton;
btnDebug: TfpgButton;
{@VFD_HEAD_END: MainForm}
public
procedure AfterCreate; override;
end;
But that is not really what I wanted. I wanted the btnDebugClick method
to be private, not published. Published is the default visibility if no
visibility is specified. The following code is actually what I wanted:
TMainForm = class(TfpgForm)
private
{@VFD_HEAD_BEGIN: MainForm}
btnCreate: TfpgButton;
btnDebug: TfpgButton;
{@VFD_HEAD_END: MainForm}
procedure btnDebugClick(Sender: TObject);
procedure btnCreateClick(Sender: TObject);
public
procedure AfterCreate; override;
end;
Even after I manually moved the btnDebugClick() event handler to the
correct location in the 'private' area, when I create the second event
handler for the Create Button, Code Tools again places the event handler
in the published section.
In Code Tools I have "Class part insert policy" set to "Last" and
"Method insert policy" set to "class order".
========================
Mantis conversion info:
- Mantis ID: 13994
- OS: Ubuntu Linux
- OS Build: 8.04.2
- Build: latest svn
- Platform: x86
- Version: 0.9.27 (SVN)
- Fixed in version: 1.5 (SVN)
- Fixed in revision: 50197 (#e3749487)