TMenuItem, How to insert esc chars like a TAB in the Caption and show "underline lazarus / 31-LCL ---------------------------------------------------------------------- jamie · 2024-10-06 19:42 As it states. Translating some C++ code, a "\t" is used for the TAB so I can get even spaced captions between the title and remainder of the caption ---------------------------------------------------------------------- TRon · 2024-10-06 19:46 usually see wikipedia but I do not know if tmenuitem captions honours that. If you have difficulty instering the caption in the object inspector then you might want and try literally writing the caption down somewhere else then copy-paste as tab does something else in the IDE. ---------------------------------------------------------------------- VisualLab · 2024-10-06 19:50 Quite a peculiar need (not that it's a criticism). Out of curiosity, I'll ask: which program uses something like that? Because I don't think I've come across anything like that before (or I'm not aware of it). ---------------------------------------------------------------------- jamie · 2024-10-06 19:53 in C/C++ you can use control chars to insert items like TABS,  new Lines etc. In this example, the 'XYZ\tABC' would result in a nicely formatted caption in the menu of "XYZ     ABC" etc. I know there is a json string function that can do this, but obviously its not in here? If you look at various menu examples the accelerator keys are spaced to the right evenly, so all menu items dropped down are formatted. ---------------------------------------------------------------------- jamie · 2024-10-06 20:05 I also noticed that while in the Menu Designer, the Acell letters are underlined, at run time, they are not? apparently Laz does not intepret strings like this for control chars, I need to fill in a property field per item, but doing so, I still don't see a underline.. I'll be back, strange it will not accept escape chars like this. ---------------------------------------------------------------------- VisualLab · 2024-10-06 20:57 Quote from: jamie on October 06, 2024, 09:53:57 pmIf you look at various menu examples the accelerator keys are spaced to the right evenly, so all menu items dropped down are formatted. Ah, that's what you mean. I just checked in Lazarus (which is written using Lazarus - LCL). Menu items (not all of them) contain keyboard shortcuts. And they are aligned to the right edge of the expanded menu. I always added information about keyboard shortcuts (accelerator keys) in the ShortCut property of a specific TMenuItem. And they always displayed nicely after showing the menu section during program runtime. Quote from: jamie on October 06, 2024, 10:05:13 pmI also noticed that while in the Menu Designer, the Acell letters are underlined, at run time, they are not? apparently Laz does not intepret strings like this for control chars, I need to fill in a property field per item, but doing so, I still don't see a underline.. I'll be back, strange it will not accept escape chars like this. They show up when you press the Alt key on your keyboard. I think in the older days (Windows 3.11 and earlier) these underlines were permanent, but then MS changed it. P.S. At least that's how it works in Windows. I don't have Linux running at the moment, but I'll try to check tomorrow. ---------------------------------------------------------------------- jamie · 2024-10-06 21:23 If you press a relative key to the menu item with the supposed underline, that LETTER is used to execute the menu item. But if you can't see it when you manually open it, it's a guess. They are supposed to be highlighted at all times whenever the "&" is Infront. You don't need the ALT+letter to execute the target menu when the menu is already opened, but it is supposed to show it, so you know what key to press. The ALT+.... only works when the menus are closed up//. ---------------------------------------------------------------------- VisualLab · 2024-10-06 22:05 Quote from: jamie on October 06, 2024, 11:23:50 pmIf you press a relative key to the menu item with the supposed underline, that LETTER is used to execute the menu item. But if you can't see it when you manually open it, it's a guess. They are supposed to be highlighted at all times whenever the "&" is Infront. You don't need the ALT+letter to execute the target menu when the menu is already opened, but it is supposed to show it, so you know what key to press. The ALT+.... only works when the menus are closed up//. I press the Alt key (the first time). The letters in the names of the main menu sections appear underlined. Then I press the Alt+... key combination (e.g. Alt+F for the "File" section). The indicated main menu section appears expanded. Then I can use the arrow keys or a keyboard shortcut. ---------------------------------------------------------------------- jamie · 2024-10-06 22:49 Yeah, but they are supposed to show when manually open the drop down. In anycase, I fixed the issue by using OWnerDraw and now they show property, also with that, there is no longer flickering in the main menu when you move the form around, which has been there for a long time. Thanks for the help. ---------------------------------------------------------------------- wp · 2024-10-06 23:11 Quote from: jamie on October 06, 2024, 09:42:27 pmHow to insert esc chars like a TAB in the Caption and show "underline As it states. Translating some C++ code, a "\t" is used for the TAB so I can get even spaced captions between the title and remainder of the caption Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormCreate(Sender:TObject);begin  MenuItem2.Caption := 'Test'#9'test';  MenuItem3.Caption := 'ABC'#9'test';  MenuItem4.Caption := 'MenuItem4'#9'test';    end;But be warned that the alignment of the part after the tab may depend on the length of the part before it... ---------------------------------------------------------------------- jamie · 2024-10-07 00:00 Yes, I got it to align the way I wanted it to show, but kind of disappointed about how the underscores are working, I also solved that with the owner draw. ---------------------------------------------------------------------- VisualLab · 2024-10-07 06:58 I have now tried the accelerator keys in various Windows programs. It turns out that the action of accelerator keys in their main menu varies (some work as expected, some do not). This means that a lot depends on the programmer, and perhaps also on the libraries, not just on the OS. Interestingly, even those written in Java work correctly (NetBeans, SceneBuilder).