Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Using OnCreateCustomEditor in TGrid causes some events to not fire


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 0
Michael Gonyea

Posts: 10
Registered: 4/6/12
Using OnCreateCustomEditor in TGrid causes some events to not fire  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 24, 2017 2:24 PM
Delphi Berlin 10.1 (Update 2)
Target Device: iOS 64-bit (iPad)

Hey folks,

I'm using a regular TGrid populated via Livebindings (data comes from a FireDAC memory table; FDMemTable) in a cross platform app and would like to override some minor editor settings in the cell's editor(s). After data is entered into specific cells, I'm planning on triggering some extra code to auto-move to the next cell (currently doing this via TGrid.OnEditingDone). If I don't create any custom editors in the OnCreateCustomEditors event, the OnEditingDone event fires normally; however, as soon as I create a custom editor in the OnCreateCustomEditors event, the event no longer fires. Here's what I have so far:

1) a TGrid populated with data via LiveBindings
2) assigned event handler for OnCreateCustomEditor


type TGridDefaultEdit = class(TEdit);
.....
procedure TSheetLineBase.gridSheetLinesCreateCustomEditor(Sender: TObject;
  const Column: TColumn; var Control: TStyledControl);
begin
  if (Column.Index >= 9) and (Column.Index <= 14) then begin
    Control := TGridDefaultEdit.Create(gridSheetLines);
 
    // set keyboard type and return key "text" for on-screen keyboard (iOS)
    TGridDefaultEdit(Control).KeyboardType := TVirtualKeyboardType.NumberPad;
    TGridDefaultEdit(Control).ReturnKeyType := TReturnKeyType.Next;
 
    // use the exact same style that TGrid's default editor uses
    Control.StyleLookup := 'textcellstyle';
  end;
end;
 
procedure TSheetLineBase.gridSheetLinesEditingDone(Sender: TObject; const ACol,
  ARow: Integer);
begin
  log('gridSheetLinesEditingDone event called; moving to next cell automatically');
  ...
end;


WIth the custom editor, I can edit data just fine, but as soon as I hit the "Return" key on the iOS on-screen keyboard, the cell contents revert back to what it was originally and does not accept/use the new value from the editor. I'm guessing I'm missing an important step here but am at a loss to figure out how to overcome this issue. Any advice?

(Note: as soon as I comment out the creation of the custom editor, the grid accepts data no problem.)

Edited by: Michael Gonyea on Feb 24, 2017 2:25 PM (added Note at bottom)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02