Implementation of Accelerator’s character: Alt+SomeKey lazarus / 31-LCL ---------------------------------------------------------------------- BrunoK · 2014-06-24 10:07 I post the code for scrutiny and test + other OS platforms test and eventual acceptance by the Lazarus developers community? 2 zipped files in 2 posts due to size limitations of attachments. lcl_lcl.zip modified files that should go to .\lcl lcl_include.zip modified files that should go to .\lcl\include All changes/additions marked with ~bk in the code I finished implementing LZDialogChar  (DialogChar) for the LCL. My Lazarus 1.2.4 version (was developed in 1.2.0) now reacts to ShortCuts, such as those defined in findreplacedialog (French version). So no more annoying BEEP when tempted to use Accelerator characters. It operates on (hope I didn’t forget some) any TControl.Caption’s with a “&” (ampersand) letter marked when allowed and relevant. Tested on Windows XP on Pentium DualCore 2.1 GHz. FPC 2.6.4 Time taken for the processing on a form with 20 - 60 potential control targets : 500mus-2.5ms (A human takes approx. 200ms between KeyDown and KeyUp). Base logic of operation: 1° - When a TWinControl receives a CN_SYSCHAR message (notification), it asks its ParentForm to recover its Enabled+Visible and Focus_Changeable controls in their TabOrder. 2° - If no Target for AccelChar -> normal BEEP 3° - A single target -> DO DEFAULT action on the Target TWinControl. 3° - Multiple targets -> Set focus to the NEXT focusable Target (Starting after the ParentForm.ActiveControl and Looping to the first in TabOrder at End of List). 3b° - Exceptions :    If TRadioButton in a GroupBox -> Set the Focus to the current selected RadioButton in the GroupBox. Special cases: If in a TCustomGroupBox, pressing (no Alt) a Key matching an AccelChar will do the action related to the Target. When a TCustomTabControl has the focus (Focus rectangle drawn on the Tab) pressing (no Alt) a Key matching an AccelChar in one of the Tabs’s caption will activate the corresponding Tab. SpaceBar set the focus to the first WinControl in the visible TCustomTabControl. TCustomGrid. If a Title Caption has a Target AccelChar the column will be activated. If single Target in the list, will also do the Column Click action. Changes : Modified TCMDialogChar in controls.pas so it can supply info to the targets function TControl.LZDialogChar (var aMessage:TCMDialogChar):Boolean; virtual; Added function T_Controls_Descendent.LZDialogChar (var aMessage:TCMDialogChar):Boolean; override; where appropriate. KeyPress override for TCustomTabControl and TCustomCheckBox. UNITS Controller unit : .\1.2.4\lcl\udialogchar.pas NEW    Classes TAccelCharTarget=class; -> descriptor of each target TControl. TAccelCharList=class(TFPList); -> controller and in TabOrder list of targets. MODIFIED UNITS, generally added udialogchar in implementation uses clause + LZDialogChar function where requested. .\1.2.4\lcl\buttons.pp .\1.2.4\lcl\comctrls.pp (TCustomTabControl.Keypress override) .\1.2.4\lcl\controls.pp (modified TCMDialogChar + message CN_SYSCHAR) .\1.2.4\lcl\grids.pas .\1.2.4\lcl\stdctrls.pp (TCustomGroupBox.KeyPress override + TCustomCheckBox.Keypress override) .\1.2.4\lcl\include\buttons.inc .\1.2.4\lcl\include\control.inc .\1.2.4\lcl\include\customcheckbox.inc (TCustomTabControl.KeyPress implementation) .\1.2.4\lcl\include\customgroupbox.inc (TCustomGroupBox.KeyPress implementation) .\1.2.4\lcl\include\customlabel.inc .\1.2.4\lcl\include\custompage.inc .\1.2.4\lcl\include\customstatictext.inc .\1.2.4\lcl\include\radiobutton.inc .\1.2.4\lcl\include\speedbutton.inc .\1.2.4\lcl\include\tabcontrol.inc .\1.2.4\lcl\include\toolbutton.inc .\1.2.4\lcl\include\wincontrol.inc Bruno K. ---------------------------------------------------------------------- BrunoK · 2014-06-24 10:07 Second part ---------------------------------------------------------------------- Mike.Cornflake · 2014-06-24 10:39 Lot's or hard work here :-)  However lcl code is under constant revision.  Which version is your code descended from?  Copying your files over the wrong version is likely to cause problems for others here. due to introduced inconsistencies between the version you wrote your code and the version the end users have installed. See http://wiki.lazarus.freepascal.org/Creating_A_Patch for how to create a patch. Instead of replacing files, patches are merged into existing files.  Inside the patch file there is sufficient information for a patch to be applied to any later revision of the code (within reason). ---------------------------------------------------------------------- BrunoK · 2014-06-24 11:26 As mentioned in the first post : Lazarus 1.2.4 extracted and build from lazarus-1.2.4-0.zip downloaded on 2014.06.20 from the download page. FPC 2.6.4 from official release fpc-2.6.4.source.zip downloaded 2014.03.31. Base development and testing done with official 1.2.0 in the last on/and off months. Plugged the modified bits from my modified 1.2.0 to a clean 1.2.4 official. All change marked "~bk" somewhere near the added/patched code. Win32 XP It does not descend from anything near, or far, already working. Built from scratch because I dislike noisy BEEPs for something that exists in a fairly standard way in Windows, Gimp and what else. It is not Delphi inspired because Delphi (DBS 2006 and before) just picks up the first matching control and that is something I do not like. Specially in developments that may have been translated without being testable due to non-functional feature. Bruno K. ---------------------------------------------------------------------- Mike.Cornflake · 2014-06-24 12:02 If you didn't post your code for inclusion into Lazarus future releases, then many thanks for sharing and ignore everything else here If you did intend for this to be included in future Lazarus releases, then I'm concerned that this is going to be overlooked by the dev team, which would be a crying shame.  You've done a lot of hard work here. In order to submit this to the dev team for inclusion in future releases, you need to follow the steps in the wiki page I posted.  Then you create an item in the Mantis Bugtracker, and attach your patch to that item.  The Mantis Bugtracker is the correct place to submit updates, not this forum. You've done all your work from the Lazarus 1.2.x code base.  This is unfortunately already stale :-(  Ongoing development has been occurring the 1.3 code base for quite a while now (a year?).  Some of the more serious issues fixed in the 1.3 code get back ported to the 1.2 code base (hence all the 1.2.x minor updates). Can you download the latest 1.3 code base (trunk), and see if these changes can be applied there?   You'll need to manually merge all your changes into the Trunk code.  Once they're all in and tested, then you can use SVN to generate the patch for you. From the first line on http://wiki.lazarus.freepascal.org/Creating_A_Patch QuoteIf you want to submit improvements to the FPC or Lazarus code, you need to submit a patch which developers can easily merge. To download Trunk http://wiki.lazarus.freepascal.org/Getting_Lazarus#Getting_Lazarus_SVN _development_version Or better yet, my personal favourite method: https://bitbucket.org/reiniero/fpcup QuoteIt does not descend from anything near, or far, already working.My fault - I guess I should have said "branched" instead of "descended".  You're correct, "descended" means something different in our world. ---------------------------------------------------------------------- BrunoK · 2014-06-24 20:43 Aie aie yes sir. I have been already buggered up by the kings here. They don't look at the source code. It is not a problem, the latest versions 1.2 + next are so good, (editor, debugger) thanks to Martin_fr + Juha +  I think blazen and other discrete developers   that it is possible to disconnect myself from the super knowledgeable people around here. Back to where I was on an impossible le thingy from march 2014. For what concerns me I, there aren't many changes to the units I touched, and I have other things to do with Object Pascal. Good health and have a nice flight