Recent

Author Topic: Alphabetical order  (Read 5204 times)

oproescu

  • New Member
  • *
  • Posts: 48
Alphabetical order
« on: July 27, 2021, 03:25:50 pm »
Hello,
Please, how can be sorted buttons, labels, edits and other components alphabetically?
Thank you in advance!


ASerge

  • Hero Member
  • *****
  • Posts: 2222
Re: Alphabetical order
« Reply #1 on: July 27, 2021, 04:05:13 pm »
Please, how can be sorted buttons, labels, edits and other components alphabetically?
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   L: TStringList;
  4.   C: TComponent;
  5. begin
  6.   L := TStringList.Create;
  7.   try
  8.     L.Sorted := True;
  9.     L.Duplicates := dupAccept;
  10.     for C in Self do
  11.       L.AddObject(C.Name, C);
  12.     ListBox1.Items := L;
  13.   finally
  14.     L.Free;
  15.   end;
  16. end;

oproescu

  • New Member
  • *
  • Posts: 48
Re: Alphabetical order
« Reply #2 on: July 28, 2021, 04:39:59 pm »
Thousands of thanks ASerge!
He tested your program and it works!
But I want, if possible, the alphabetical order to be done in the box with components, as in the attached picture.
With gratitude
Yours, Tavi


Handoko

  • Hero Member
  • *****
  • Posts: 5129
  • My goal: build my own game engine using Lazarus
Re: Alphabetical order
« Reply #3 on: July 28, 2021, 04:58:19 pm »
That box is called Object Inspector. You can reorder the items inside Object Inspector by:

1. Right click the item you want to reorder
2. Click Z-Order
3. Select Move to Front/Back or Forward/Back One


For you information, there are cases you have to set the z-order in certain order (not alphabetically). For example if several objects are overlapped on the form.
« Last Edit: July 28, 2021, 05:05:03 pm by Handoko »

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Alphabetical order
« Reply #4 on: July 28, 2021, 05:02:21 pm »
Hi!

The alphabetical sorting of the components in the OI is not possible because they are sorted in the Z-order. The last entry is the topmost position and vice versa.

Use the filter on top of the OI.

Winni


oproescu

  • New Member
  • *
  • Posts: 48
Re: Alphabetical order
« Reply #5 on: July 29, 2021, 07:17:30 pm »
Thanks, Handoko!
I knew the method, but it is difficult compared to Delphi where alphabetical ordering is done automatically.
I thought there was a setting in Lazarus that allowed this, but Winni convinced me it wasn't possible.

The topic is closed.

Graham1

  • Jr. Member
  • **
  • Posts: 57
Re: Alphabetical order
« Reply #6 on: July 30, 2021, 10:54:28 pm »
That box is called Object Inspector. You can reorder the items inside Object Inspector by:

1. Right click the item you want to reorder
2. Click Z-Order
3. Select Move to Front/Back or Forward/Back One


For you information, there are cases you have to set the z-order in certain order (not alphabetically). For example if several objects are overlapped on the form.

For me that is the most annoying part of the IDE. I like to keep the items in the OI in the same order as on the screen as it makes it easier for me to find things there.

For Tab order you have options for resorting and a quick up/down arrow movement. But for Z-order you have to do it one move at a time doing right clicks for each move. I wish there was an 'Amend  Z-order' option like the Tab order box, or a cut/paste operation: right click 'Move from here...' and then right click '...To here'. At the moment the fastest way to do it is to completely reorder all of the items by right clicking each in order and doing 'Move to front' until the first one moved ends up at the back.
Windows 10/11 Home 64-bit (and Linux because I have to)
Lazarus 2.0.12 / FPC 3.2.0 (because libQt5pas 1.2.6)
Linux Mint 20 (because GLIBC_2.31)

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: Alphabetical order
« Reply #7 on: July 30, 2021, 11:04:53 pm »
At the moment the fastest way to do it is to completely reorder all of the items by right clicking each in order and doing 'Move to front' until the first one moved ends up at the back.
Using the keyboard is faster: SHIFT+PgUp moves the selected component to the front, SHIFT+PgDown moves is to the back. and CTRL+PgUp and CTRL+PgDown move it up and down by one (these keyboard shortcouts are displayed in the Z order context menu).

Graham1

  • Jr. Member
  • **
  • Posts: 57
Re: Alphabetical order
« Reply #8 on: July 31, 2021, 07:59:23 am »
At the moment the fastest way to do it is to completely reorder all of the items by right clicking each in order and doing 'Move to front' until the first one moved ends up at the back.
Using the keyboard is faster: SHIFT+PgUp moves the selected component to the front, SHIFT+PgDown moves is to the back. and CTRL+PgUp and CTRL+PgDown move it up and down by one (these keyboard shortcouts are displayed in the Z order context menu).

I was about to post that my Lazarus doesn't show the shortcuts and that the shortcuts you gave don't work. Then I discovered the problem. I have always changed the Z-order in Object Inspector, which behaves how I described. But I have just found that the Z-order context menu in the actual form DOES show the shortcuts and they do work! I have no idea why there are two different Z-order context menus but at least now I know how to do it.

Thanks!
Windows 10/11 Home 64-bit (and Linux because I have to)
Lazarus 2.0.12 / FPC 3.2.0 (because libQt5pas 1.2.6)
Linux Mint 20 (because GLIBC_2.31)

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Alphabetical order
« Reply #9 on: July 31, 2021, 10:39:39 am »
Hi!

Main Menu --> Tools --> Editor -->Key Mapping --> Designer Commands --> Move component to front / to back / one forward / one backward

Winni

 

TinyPortal © 2005-2018