Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-06

Code Completion tuning question

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

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
     MainForm}
    btnCreate: TfpgButton;
    btnDebug: TfpgButton;
     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
     MainForm}
    btnCreate: TfpgButton;
    btnDebug: TfpgButton;
     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
     MainForm}
    btnCreate: TfpgButton;
    btnDebug: TfpgButton;
     MainForm}
    procedure btnDebugClick(Sender: TObject);
    procedure btnCreateClick(Sender: TObject);
  public
    procedure AfterCreate; override;
  end;

Is there any way I can tune my Code Completion to do this? If so, what settings must I change? Or is that something hard-coded into Code Completion that cannot be changed?

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".

Regards,
- Graeme -

_______________________________________________________ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Mattias Gaertner
to Graeme Geldenhuys
Show quoted text 74 lines
Hi, 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 MainForm} btnCreate: TfpgButton; btnDebug: TfpgButton; 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 MainForm} btnCreate: TfpgButton; btnDebug: TfpgButton; 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 MainForm} btnCreate: TfpgButton; btnDebug: TfpgButton; MainForm} procedure btnDebugClick(Sender: TObject); procedure btnCreateClick(Sender: TObject); public procedure AfterCreate; override; end; Is there any way I can tune my Code Completion to do this? If so, what settings must I change? Or is that something hard-coded into Code Completion that cannot be changed? 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".

At the moment the events are always added to the first published section.

You can create a feature request for an option. For example first published, public, protected, private, ask. "Ask" will popup a dialog. Don't forget to make a nice proposal for the option name.

Mattias

Reply by email

Graeme Geldenhuys
to Mattias Gaertner
Mattias Gaertner wrote
At the moment the events are always added to the first published section.

Thanks Mattias. Feature request has been added.

http://bugs.freepascal.org/view.php?id=13994

To keep with the rest of the naming conventions used in the "Code Completion" screen I suggested the new option be called "Event insert policy". Not very original, but I think it is clear enough. ;-)

Regards,
- Graeme -

_______________________________________________________ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email