Forum > RichMemo

[SOLVED] Disallow selection TRichMemo

<< < (2/2)


--- Quote ---are you trying to use RichMemo as a rich-text Label?

--- End quote ---


--- Quote ---Maybe you simply want to set to "ReadOnly := true". It doesn't prevent the selection... but maybe you don't want to prevent the selection after all?
--- End quote ---

I did that. I need to prevent text selection and focus. Allowing text selection and focus may interfere with other controls that do requires focus. I am writing experiments for researchers and I really don't want participants playing around with the message presented.  :D

For me, changing colors is not feasible. Too much work.

Can you confirm how complicated implementing a RichMemo.SelectableText and a RichMemo.WantFocus properties would be? I choose RichMemo because in some cases people may want a long message with vertical scroll and a simple label can't do that. In that case the control would receive focus with no text selection.


Right now I am considering using for markup labels


--- Quote ---And you can always set SetLength to zero, for OnSelhange event.
--- End quote ---

Will try this alternative and see what happens.

For unselecting this code works great:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  if RichMemo1.SelLength > 0 then begin    RichMemo1.SelLength := 0;  end;    

For removing the focus, I am afraid the issue is unresolved for Lazarus (at least in the last 7 years!):

I tried

  DefocusControl(RichMemo1, False);
  DefocusControl(RichMemo1, True);
  Self.ActiveControl := nil;

In different events and nothing seems to work when you have just one control in a form.

I will create another topic for that as needed.


[0] Message Index

[*] Previous page

Go to full version