Recent

Author Topic: Renaming controls event procedures  (Read 4113 times)

frakno

  • Jr. Member
  • **
  • Posts: 88
Renaming controls event procedures
« on: July 27, 2016, 12:05:10 pm »
Hello everybody,
I want to change the name of Controls for better readability of the code.

What is the easiest way to do this?
I think my way to search+replace the current procedure name
and adjust the procedure name in object inspector is not the best one.

Thank you for an advice
Lazarus 1.6 FPC 3.0 Windows 10

bylaardt

  • Sr. Member
  • ****
  • Posts: 309
Re: Renaming controls event procedures
« Reply #1 on: July 27, 2016, 01:57:24 pm »
Ctrl+A
Ctrl+J

frakno

  • Jr. Member
  • **
  • Posts: 88
Re: Renaming controls event procedures
« Reply #2 on: July 27, 2016, 02:44:14 pm »
Thanks, but this does not solve the necessary change of the corresponding Notification handler in the object inspector
respectively in the corresponding .lfm file

if i change in my unit with Ctrl+A Ctrl+J eg.   BenPnl_PwResetClick   to   PwResetBtn,
the   value OnClick   in   the .lfm file   and the   object-inspector-event OnClick   remains OnClick = BenPnl_PwResetClick

Code: Pascal  [Select][+][-]
  1.       object BenPnl_PwReset: TfButton
  2.         Left = 370
  3.         ...
  4.         OnClick = BenPnl_PwResetClick
  5.         ...
  6.       end
and i get a compile error till i change the OnClick manually
« Last Edit: July 27, 2016, 02:52:14 pm by frakno »
Lazarus 1.6 FPC 3.0 Windows 10

Handoko

  • Hero Member
  • *****
  • Posts: 5150
  • My goal: build my own game engine using Lazarus
Re: Renaming controls event procedures
« Reply #3 on: July 27, 2016, 02:57:37 pm »
Open the *.lfm files and use Find/Replace feature on your favorite text editor. Notepad.exe if you use Windows, or Gedit / Pluma if you're a Linux user.
« Last Edit: July 27, 2016, 03:00:27 pm by Handoko »

bylaardt

  • Sr. Member
  • ****
  • Posts: 309
Re: Renaming controls event procedures
« Reply #4 on: July 27, 2016, 04:55:45 pm »
Thanks, but this does not solve the necessary change of the corresponding Notification handler in the object inspector
respectively in the corresponding .lfm file
open the .lfm file too:
right-click over the form/view source (.lfm)
then
Ctrl+A
Ctrl+J

FTurtle

  • Sr. Member
  • ****
  • Posts: 292
Re: Renaming controls event procedures
« Reply #5 on: July 27, 2016, 05:37:20 pm »
You can rename procedure name in Object Inspector at Events tab. Then procedure will renamed in code too.
As for refactoring/rename identifier, there are few bugreports on this theme:
http://bugs.freepascal.org/view.php?id=26563
http://bugs.freepascal.org/view.php?id=13843
http://bugs.freepascal.org/view.php?id=29423
http://bugs.freepascal.org/view.php?id=29423



frakno

  • Jr. Member
  • **
  • Posts: 88
Re: Renaming controls event procedures
« Reply #6 on: July 27, 2016, 10:19:00 pm »
Really great!
First attempts are successful, will test on remaining bugs
and perform a backup before major changes
Lazarus 1.6 FPC 3.0 Windows 10

 

TinyPortal © 2005-2018