Should navigating to a TDBEdit trigger insertion? lazarus / 16-Databases ---------------------------------------------------------------------- vfclists · 2016-02-24 14:45 I have a database form which automatically enters editing mode when I navigate to a TDBEdit. Is that normal intended behaviour? ---------------------------------------------------------------------- Thaddy · 2016-02-24 15:00 Yes. It isn't called TDBEdit for nothing. But you can modify it into readonly to have the behavior you seem to expect and put it in edit mode afterwards. ---------------------------------------------------------------------- vfclists · 2016-02-24 16:48 Quote from: Thaddy on February 24, 2016, 04:00:59 pmYes. It isn't called TDBEdit for nothing. But you can modify it into readonly to have the behavior you seem to expect and put it in edit mode afterwards. I don't think that should be the behaviour. You have to start entering keystrokes before it switches to edit mode. In my experience that is not the behaviour, unless that has been the usual behaviour and I failed to notice. ---------------------------------------------------------------------- balazsszekely · 2016-02-24 17:20 It should only switch to edit mode when you start entering keystrokes. Must be something else involved...Do you have event(s) assigned to TDBEdit, Datasource, Dataset? Anyway if you don't find out the reason(feel free to attach a test project if necessary), as a quick fix set AutoEdit to False(TDataSource), then enter into edit mode manually, when necessary. 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 uses db;//...if not (qTest.State in [dsEdit, dsInsert]) then  qTest.Edit; ---------------------------------------------------------------------- Thaddy · 2016-02-24 18:35 Afaik it goes to edit mode when it receives focus. ---------------------------------------------------------------------- rvk · 2016-02-24 19:19 Quote from: Thaddy on February 24, 2016, 07:35:37 pmAfaik it goes to edit mode when it receives focus. I do see the FDataLink.Edit in TDBEdit.WMSetFocus (can't test it right now). But if that's the case I think it behaves different from Delphi where gaining focus does not switch the dataset to edit (afaik). ---------------------------------------------------------------------- mangakissa · 2016-02-25 08:50 Quote from: Thaddy on February 24, 2016, 07:35:37 pmAfaik it goes to edit mode when it receives focus. If the DBEdit get focused and the dataset.state is set to edit you can not scroll to the dataset. Getmem is right. @rvk Delphi and FPC has the same way of setting a dataset.state into the editmode. ---------------------------------------------------------------------- rvk · 2016-02-25 09:27 I just checked for Lazarus 1.6 and Delphi XE to be sure. In both, the SQLQuery1 does not get switched to Edit state, when a TDBEdit gets focus. ---------------------------------------------------------------------- mangakissa · 2016-02-25 11:16 it's simply to test it with several records. If you're in edit mode, you can't scroll. Even Lazarus results in an error and wants you to close the application. ---------------------------------------------------------------------- vfclists · 2016-02-25 11:47 There is an event attached to OnNewRecord which sets a default for one of the fields, but I still don't think it should be triggered until I start editing. I will test it later when I get the chance. I am currently using 1.4.4 Quote from: GetMem on February 24, 2016, 06:20:02 pmIt should only switch to edit mode when you start entering keystrokes. Must be something else involved...Do you have event(s) assigned to TDBEdit, Datasource, Dataset? Anyway if you don't find out the reason(feel free to attach a test project if necessary), as a quick fix set AutoEdit to False(TDataSource), then enter into edit mode manually, when necessary. 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 uses db;//...if not (qTest.State in [dsEdit, dsInsert]) then  qTest.Edit; ---------------------------------------------------------------------- balazsszekely · 2016-02-25 13:05 Are you working under OSX? Because I can reproduce the error there. Apparently WidgetSet.GetLCLCapability return LCL_CAPABILITY_NO on carbon, so instead of Reset the DataLink will jump to Edit mode.