FormControlEditLink Focus Retention

I am having difficulty using FormControlEditLink because it seems that it always retains focus. For example, if the control is linked to a tadvedit and the advedit is the active inplace editor in the cell, the first click of a command button (eg a tbutton) will end editing of the cell and it takes a subsequent click for the tbutton's onclick handler to fire. This is different from the behavior of the control-specific links you have provided (eg. tadvediteditlink). To see the difference, run the example below and edit a cell in column 1 and then click the tbutton -- the button does not fire on the first click. Repeat in column 2 and you will see that the advediteditlink allows the button's onclick handler to fire.

Is there a setting in Formcontroleditlink that can be changed so that it does not retain focus in this manner?


object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 347
  ClientWidth = 635
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object AdvStringGrid1: TAdvStringGrid
    Left = 56
    Top = 8
    Width = 400
    Height = 250
    Cursor = crDefault
    BiDiMode = bdLeftToRight
    ColCount = 3
    DrawingStyle = gdsClassic
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Tahoma'
    Font.Style = []
    Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goFixedRowClick]
    ParentBiDiMode = False
    ParentFont = False
    ScrollBars = ssBoth
    TabOrder = 0
    HoverRowCells = [hcNormal, hcSelected]
    OnGetEditorType = AdvStringGrid1GetEditorType
    ActiveCellFont.Charset = DEFAULT_CHARSET
    ActiveCellFont.Color = clWindowText
    ActiveCellFont.Height = -11
    ActiveCellFont.Name = 'Tahoma'
    ActiveCellFont.Style = [fsBold]
    ColumnHeaders.Strings = (
      ''
      'Formcontroleditlink'
      'AdvEditEditLink')
    ControlLook.FixedGradientHoverFrom = clGray
    ControlLook.FixedGradientHoverTo = clWhite
    ControlLook.FixedGradientDownFrom = clGray
    ControlLook.FixedGradientDownTo = clSilver
    ControlLook.DropDownHeader.Font.Charset = DEFAULT_CHARSET
    ControlLook.DropDownHeader.Font.Color = clWindowText
    ControlLook.DropDownHeader.Font.Height = -11
    ControlLook.DropDownHeader.Font.Name = 'Tahoma'
    ControlLook.DropDownHeader.Font.Style = []
    ControlLook.DropDownHeader.Visible = True
    ControlLook.DropDownHeader.Buttons = <>
    ControlLook.DropDownFooter.Font.Charset = DEFAULT_CHARSET
    ControlLook.DropDownFooter.Font.Color = clWindowText
    ControlLook.DropDownFooter.Font.Height = -11
    ControlLook.DropDownFooter.Font.Name = 'Tahoma'
    ControlLook.DropDownFooter.Font.Style = []
    ControlLook.DropDownFooter.Visible = True
    ControlLook.DropDownFooter.Buttons = <>
    Filter = <>
    FilterDropDown.Font.Charset = DEFAULT_CHARSET
    FilterDropDown.Font.Color = clWindowText
    FilterDropDown.Font.Height = -11
    FilterDropDown.Font.Name = 'Tahoma'
    FilterDropDown.Font.Style = []
    FilterDropDown.TextChecked = 'Checked'
    FilterDropDown.TextUnChecked = 'Unchecked'
    FilterDropDownClear = '(All)'
    FilterEdit.TypeNames.Strings = (
      'Starts with'
      'Ends with'
      'Contains'
      'Not contains'
      'Equal'
      'Not equal'
      'Larger than'
      'Smaller than'
      'Clear')
    FixedRowHeight = 22
    FixedFont.Charset = DEFAULT_CHARSET
    FixedFont.Color = clWindowText
    FixedFont.Height = -11
    FixedFont.Name = 'Tahoma'
    FixedFont.Style = [fsBold]
    FloatFormat = '%.2f'
    HoverButtons.Buttons = <>
    HoverButtons.Position = hbLeftFromColumnLeft
    HTMLSettings.ImageFolder = 'images'
    HTMLSettings.ImageBaseName = 'img'
    MouseActions.DirectEdit = True
    PrintSettings.DateFormat = 'dd/mm/yyyy'
    PrintSettings.Font.Charset = DEFAULT_CHARSET
    PrintSettings.Font.Color = clWindowText
    PrintSettings.Font.Height = -11
    PrintSettings.Font.Name = 'Tahoma'
    PrintSettings.Font.Style = []
    PrintSettings.FixedFont.Charset = DEFAULT_CHARSET
    PrintSettings.FixedFont.Color = clWindowText
    PrintSettings.FixedFont.Height = -11
    PrintSettings.FixedFont.Name = 'Tahoma'
    PrintSettings.FixedFont.Style = []
    PrintSettings.HeaderFont.Charset = DEFAULT_CHARSET
    PrintSettings.HeaderFont.Color = clWindowText
    PrintSettings.HeaderFont.Height = -11
    PrintSettings.HeaderFont.Name = 'Tahoma'
    PrintSettings.HeaderFont.Style = []
    PrintSettings.FooterFont.Charset = DEFAULT_CHARSET
    PrintSettings.FooterFont.Color = clWindowText
    PrintSettings.FooterFont.Height = -11
    PrintSettings.FooterFont.Name = 'Tahoma'
    PrintSettings.FooterFont.Style = []
    PrintSettings.PageNumSep = '/'
    SearchFooter.FindNextCaption = 'Find &next'
    SearchFooter.FindPrevCaption = 'Find &previous'
    SearchFooter.Font.Charset = DEFAULT_CHARSET
    SearchFooter.Font.Color = clWindowText
    SearchFooter.Font.Height = -11
    SearchFooter.Font.Name = 'Tahoma'
    SearchFooter.Font.Style = []
    SearchFooter.HighLightCaption = 'Highlight'
    SearchFooter.HintClose = 'Close'
    SearchFooter.HintFindNext = 'Find next occurrence'
    SearchFooter.HintFindPrev = 'Find previous occurrence'
    SearchFooter.HintHighlight = 'Highlight occurrences'
    SearchFooter.MatchCaseCaption = 'Match case'
    SortSettings.DefaultFormat = ssAutomatic
    Version = '7.8.9.0'
    ColWidths = (
      64
      127
      126)
  end
  object Button1: TButton
    Left = 72
    Top = 286
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 1
    OnClick = Button1Click
  end
  object AdvEdit1: TAdvEdit
    Left = 184
    Top = 288
    Width = 121
    Height = 21
    EmptyTextStyle = []
    LabelFont.Charset = DEFAULT_CHARSET
    LabelFont.Color = clWindowText
    LabelFont.Height = -11
    LabelFont.Name = 'Tahoma'
    LabelFont.Style = []
    Lookup.Font.Charset = DEFAULT_CHARSET
    Lookup.Font.Color = clWindowText
    Lookup.Font.Height = -11
    Lookup.Font.Name = 'Arial'
    Lookup.Font.Style = []
    Lookup.Separator = ';'
    Color = clWindow
    TabOrder = 2
    Text = 'AdvEdit1'
    Visible = True
    Version = '3.3.6.1'
  end
  object FormControlEditLink1: TFormControlEditLink
    Tag = 0
    WantKeyLeftRight = False
    WantKeyUpDown = False
    WantKeyHomeEnd = False
    WantKeyPriorNext = False
    Control = AdvEdit1
    Left = 360
    Top = 280
  end
  object AdvEditEditLink1: TAdvEditEditLink
    Tag = 0
    WantKeyLeftRight = True
    WantKeyUpDown = False
    WantKeyHomeEnd = True
    WantKeyPriorNext = False
    EditAlign = eaLeft
    EditColor = clWindow
    MaxLength = 0
    ModifiedColor = clRed
    EditType = etString
    ShowModified = False
    Precision = 0
    Signed = False
    ExcelStyleDecimalSeparator = False
    Left = 456
    Top = 288
  end
end


unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, AdvObj, BaseGrid, AdvGrid,
  Vcl.StdCtrls, frmctrllink, AsgLinks, Vcl.Mask, JvExMask, JvToolEdit, AdvEdit;

type
  TForm1 = class(TForm)
    AdvStringGrid1: TAdvStringGrid;
    FormControlEditLink1: TFormControlEditLink;
    Button1: TButton;
    AdvEdit1: TAdvEdit;
    AdvEditEditLink1: TAdvEditEditLink;
    procedure Button1Click(Sender: TObject);
    procedure AdvStringGrid1GetEditorType(Sender: TObject; ACol, ARow: Integer;
      var AEditor: TEditorType);
  private
    { Private declarations }
  public

    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.AdvStringGrid1GetEditorType(Sender: TObject;
  ACol, ARow: Integer; var AEditor: TEditorType);
begin
  AEditor := edCustom;
  Case ACol of
    1:
      begin
        AdvStringGrid1.EditLink := FormControlEditLink1;
      end;
    2:
      begin
        AdvStringGrid1.EditLink := AdvEditEditLink1;
      end;

  end;

end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage('clicked');
end;

end.

Are you using the latest version of the components?
I have retested this here with the latest version and I could not see this issue. I could not see a difference between a click on the button when the inplace editor is on column 1 and when it is on column 2.

Yes, I am using the latest version.


When you run the program be sure to do the following sequence:
Click cell 1,1 a single time
Click button 1. Result: no message displaced
Click cell 2,1
Click button 1: Result: message box displayed
Click cell 1,1
Click button1: Result: no message box

Here is a link to a video demonstrating the issue. The program in the video is from the same source code as listed above. https://youtu.be/A2876lx6fdQ

I have retested this here one more time but cannot reproduce this.
Can you perform a runtime check on the TAdvStringGrid to verify you effectively compile & link with the latest version 7.9.0.1.

Yes, the version is correct. I added the code below and 

I added the code below and the caption displayed "7.9.0.1 Dec. 2015"
Additional info: I am using Windows 10, Delphi XE7

procedure TForm1.FormCreate(Sender: TObject);
begin
Caption := AdvStringGrid1.VersionString;
end;


More info:

I repeated the test under Windows 10, Delphi XE2. My XE2 install has no other 3rd party tools installed and the paths are nothing but the default paths. The problem was reproduced.

Can you reproduce this on multiple machines?

I retested this once more on Windows 10 with XE7, D10 Seattle,... but nowhere I can see this issue.

I retested on a machine that I do not use for development. Windows 10, clean install of XE7 Pro and current TMS Component pack. The problem was reproduced on this machine. 


Perhaps we could arrange a remote login for you if that would help you in tracking this down. Alternatively, if you care to produce a version that logs debugging info I would be happy to run the code and return the results to you.

Thank you,
Tom

Can you download & run the compiled test app on your machines?

http://www.tmssoftware.net/public/editlink_test.zip 
With this app, we cannot see any issue here. If this works for you and not your own app, please inform what's different in your app. The test app we created was compiled with XE7.

The compiled app you sent works as expected  - both columns display the message on the first click. Regarding your question about what is different when I compile it, your version display a different grid version -- your grid is 7.9.0.3, not the published 7.9.0.1 that displays when I compile from the latest downloaded version (downloaded with the TMS Subscription Manager). When I compile it the control does not behave as expected -- it behaves as described above and shown in the video. 


As noted above, this can be produced on a clean install of XE7 Update1 (although the problem is also present with XE2) + clean install of the TMS products (Asvstringgrid1 7.9.0.1). Was your EXE compiled under comparable conditions? Have you tested by installing the exact code you are distributing through subscription manager?   I am using XE7 Update 1 with completely default settings. Are you using non-default compiler settings?

We always use default compiler settings for testing. I have also especially retested this with 7.9.0.1 on XE,XE6,XE7,D10 on both Windows 7 & Windows 10 and in no circumstances, I could see this issue. The updated test with 7.9.0.1 can be downloaded here:

http://www.tmssoftware.net/public/editlink_test_7901.zip