WPCubed Product Support

ReadOnly won't be set

D2009, WP6.29.1

In the form constructor I set WPRichText1.ReadOnly to true but reading it immediately after the assignment, it's false.

The Culprit seems to be this little chap:

function TWPCustomRtfEdit.GetReadOnly: Boolean;
begin
Result := FReadonly and (Memo._NotingIsProtected = 0);
end;

where _NothingIsProtected is 1.

Not sure if this is relevant, but the ProtectedProps is:

[ppParProtected
,ppCheckAllText
,ppProtected
,ppAllowEditAtTextEnd
,ppProtectSelectedTextToo]

I need this edit window to be readonly so users doesn't assume they got edit-access right until they try to save the document.

Why is _NothingIsProtected not zero, and why is it overriding the readonly state? Shouldn't it be a component-global setting? A best approach to set the editor readonly, is greatly appreciated.

Thanks in advance

#1 ♥ 0
5.1k Views 2 users read 1 min

(FIXED, I guess)

When I decide to make editor readonly I run this command:

if SetRO then
WPRichText1.Memo.EnableProtection;

which decrements the variable to zero, thus enabling the the ReadOnly := true assignment. ... but only when _NotingIsProtected counter reaches zero.

#2 ♥ 0
support

Memo.DisableProtection;

and

Memo.EnableProtection;

Should be only called in pairs, in try ... finally end statements.

To make the component readonly use Readonly and the propety EditOptions.

#3 ♥ 0
This category is archived. No new posts are possible.