Dimitri Posted January 8, 2020 Share Posted January 8, 2020 Hi, How can we catch the Return Key or the Escape Key with the BeforeCellKeyDown event in a FDBGrid ? Thank you Attached to this message is a simple testcase. UniGUI: 1.90.0.1513 EnterKeyDown_ToSend.rar Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 9, 2020 Share Posted January 9, 2020 12 hours ago, Dimitri said: How can we catch the Return Key or the Escape Key with the BeforeCellKeyDown event in a FDBGrid ? Sorry, can you please explain in more detail? 12 hours ago, Dimitri said: Attached to this message is a simple testcase. How should we work with the testcase? Quote Link to comment Share on other sites More sharing options...
Dimitri Posted January 9, 2020 Author Share Posted January 9, 2020 I use the BeforeCellKeydown event in ClientEvents.Ext Events : beforecellkeydown=function beforecellkeydown(sender, td, cellIndex, record, tr, rowIndex, e, eOpts) { var key = e.getKey(); ajaxRequest(this, "BeforeCellKeyDown", ["keycode="+key], false); return true; } Then on the UniDBGRid1.OnAjaxEvent : procedure TMainForm.UniDBGrid1AjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); var lKey: Integer; begin if EventName = 'BeforeCellKeyDown' then begin lKey := Params['keycode'].AsInteger; UniMemo1.Lines.Add(IntToStr(lKey)); end; end; When you are editing a cell, the key pressed is displayed in the memo to the right of the grid. For example, if I press the "A" key, the number 65 is displayed in the memo. If I press the "Tab" key, the number 9 is displayed in the memo. But I can't display the number of the "Return" key in the memo. It also doesn't work with the "Escape" key. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 9, 2020 Share Posted January 9, 2020 1 hour ago, Dimitri said: When you are editing a cell, the key pressed is displayed in the memo to the right of the grid. For example, if I press the "A" key, the number 65 is displayed in the memo. If I press the "Tab" key, the number 9 is displayed in the memo. But I can't display the number of the "Return" key in the memo. It also doesn't work with the "Escape" key. It works for me. But with one excluding of course: The following sequence doesn't work Enter (works) -> ESC (doesn't work) (and this is normal...) What do you want to achieve? Quote Link to comment Share on other sites More sharing options...
Dimitri Posted January 9, 2020 Author Share Posted January 9, 2020 Ok, thanks for your answer. I would like to know when the user presses the Return key to exit the cell edition. Is there any way to know that? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 9, 2020 Share Posted January 9, 2020 Perhaps you need to use another event for this. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 9, 2020 Share Posted January 9, 2020 Or use the "specialkey" event for the column editor: Quote Link to comment Share on other sites More sharing options...
Dimitri Posted January 10, 2020 Author Share Posted January 10, 2020 It works ! Thanks. function reconfigure(sender, store, columns, oldStore, oldColumns, eOpts) { var grid = sender; for (var i = 0; i < columns.length; i++) { if (columns[i].getEditor()) { columns[i].getEditor().on('specialkey', function(field, e) { if (e.getKey() == 13) { ajaxRequest(grid, "BeforeCellKeyDown", ["keycode=13"], false); return e.keyCode; } }) } } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.