Conversation
A plain RTTI write to a TDBEdit / TDBMemo / TDBCheckBox only changes the window text: the dataset never enters dsEdit and DataLink.UpdateRecord never runs, so the value is discarded on the next scroll. A typing user gets both through KeyPress/Toggle (DataLink.Edit) and CMExit (DataLink.UpdateRecord). set_text now resolves DataField -> DataSource -> DataSet via RTTI, calls DataSet.Edit before the write and sends CM_EXIT after it. set_checked toggles a data-aware checkbox through BM_CLICK (Toggle is protected and is the only path that marks the link modified) and sends CM_EXIT. Both responses carry dataBound so the caller can see that the chain ran. RTTI only, no Data.DB dependency; FMX unchanged. Tool descriptions and AI-INSTRUCTIONS.md updated. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Review follow-up on the data-aware set_text / set_checked: - Go through DataSource.Edit instead of DataSet.Edit so Enabled/AutoEdit apply, and refuse up front (-32005 with the reason) what the VCL refuses a typing user: control ReadOnly, field not modifiable (read-only, calculated, lookup), dataset CanModify = FALSE, AutoEdit = FALSE while not in dsEdit/dsInsert. A dataset the app already put into edit mode is left alone. Edit exceptions (OnBeforeEdit Abort) are reported, not passed on as a bare internal error. - Check for a writable Text before entering edit mode: TDBLookupComboBox (read-only Text) and TDBRadioGroup (Caption fallback) no longer leave the dataset in dsEdit with nothing written. - set_checked: no Edit up front (Toggle does it), HandleNeeded, re-read Checked after BM_CLICK, second click for the AllowGrayed step, fail when the state did not change. - Docs: verified controls named (TDBEdit, TDBMemo), refusal rules and the BM_CLICK focus side effect documented, TDBComboBox marked untested. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Owner
|
Thank you, Martin! Your change is included in main and will ship in a few days. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
set_texton a VCL data-aware control (TDBEdit,TDBMemo, ...) writesTextvia RTTI. That only changes the window text:DataLink.Editnever runs (the dataset stays indsBrowse,TDBEditeven keeps its Windows edit read-only) andDataLink.UpdateRecordnever runs, so the value is silently discarded on the next scroll. A user typing into the control gets both throughKeyPressandCMExit. Same forset_checkedonTDBCheckBox: a directCheckedwrite never marks the link modified.Change
set_text: when the component has a publishedDataField <> ''and aDataSourcewith aDataSet, callDataSet.Editbefore the write (enteringdsEditfiresDataChange, which would overwrite a value written earlier) andPerform(CM_EXIT)after it (the control'sCMExitrunsUpdateRecord, then the regularOnExit).set_checked: a data-aware checkbox is toggled throughBM_CLICK(synchronousPerform;BN_CLICKED->Toggle->DataLink.Edit+Modified) only when the state has to change, thenCM_EXIT.dataBound: true|false.DataField->DataSource->DataSet->Edit/CanModify), so the bridge has noData.DBdependency and non-database apps link nothing extra. FMX untouched.AI-INSTRUCTIONS.mdupdated.Refusals (same rules as for a typing user, reported as
-32005with the reason)Control
ReadOnly, field not modifiable (read-only/calculated/lookup), datasetCanModify = FALSE,DataSource.AutoEdit = FALSEwhile not indsEdit/dsInsert,OnBeforeEditabort, data-aware control without a writableText(TDBLookupComboBox,TDBRadioGroup). A dataset the app already put into edit mode is left alone.set_checkedre-readsCheckedafterBM_CLICK(second click for theAllowGrayedstep) and fails when the toggle was refused.Tested
Delphi 13 (37.0), VCL app with
TDBMemobound to aTADODataSet(SQL Server):set_text->dataBound: true, dataset indsEdit, field buffer holds the value, form's Save button persisted it, re-read from DB matched. Before the change the same call left the dataset indsBrowseand the value was lost.🤖 Generated with Claude Code