Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » RichTextCtrl - cannot clear selected text. [Fixed] (Need a new method or is there a way to do it I'm missing?)
RichTextCtrl - cannot clear selected text. [Fixed] [message #58342] Sun, 01 May 2022 14:06 Go to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 220
Registered: June 2011
Experienced Member
I'm trying to clear the selected text when focus is lost but I can't find any method to do it and .text is private so I can't adjust anchor/cursor from there either. Could we add a method to clear or cancel the selected text or is there another way to do it that I missed?

I see a potential problem with this approach. If you try to right click copy, the context menu steals the focus.

Oops, I appeared to have put this topic in the wrong place. Sorry about that.

[Updated on: Mon, 16 May 2022 14:25]

Report message to a moderator

Re: RichTextCtrl - cannot clear selected text. [message #58385 is a reply to message #58342] Mon, 16 May 2022 10:46 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Have you tried

my_rich_text_ctrl <<= Null;

?
Re: RichTextCtrl - cannot clear selected text. [message #58387 is a reply to message #58385] Mon, 16 May 2022 11:11 Go to previous messageGo to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 220
Registered: June 2011
Experienced Member
Mirek,
I should be clearer about what I'm doing. I have a bunch of RichTextCtrls (potentially thousands - it's for a chat application) in a scrollable view and when text is selected for copy+paste the selection is not cleared when I select another RichTextCtrl. Unless I'm unaware of something <<= will clear the text itself (not what I want) but not the highlighted selection.

The other thing I want to do is virtualize the scrollable view so I don't have so many RichTextCtrls open at the same time but that's a question I posted elsewhere.
Re: RichTextCtrl - cannot clear selected text. [message #58388 is a reply to message #58385] Mon, 16 May 2022 11:15 Go to previous messageGo to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 220
Registered: June 2011
Experienced Member
The section of code I could use is contained in Clear()

void  RichTextView::Clear()
{
	sb = 0;
	text.Clear();
	SetSb();
	Refresh();
	anchor = cursor = sell = selh = 0;
}


Just

anchor = cursor = sell = selh = 0;


Is enough to clear the selected text but all of this stuff is inaccessible and private.
Re: RichTextCtrl - cannot clear selected text. [message #58389 is a reply to message #58388] Mon, 16 May 2022 12:00 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Ah, that is a bug. Fixed.

As for your other problem, have you considered to have just single RichTextCtrl? You can put whole bunch of things inside as links (including images) and react to those.

Worked pretty well for me in the past.

Mirek
Re: RichTextCtrl - cannot clear selected text. [message #58390 is a reply to message #58389] Mon, 16 May 2022 12:22 Go to previous messageGo to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 220
Registered: June 2011
Experienced Member
Cool, I'll check it out.

Yes, I originally started with a single RichTextCtrl but this client does more than just displaying text or images, it has to be able to do custom mouseovers with active elements, transitions, embedded video and audio, Downloadable files and each element has to be trackable, searchable, updateable, deleteable and it ideally should support group-level encryption. RichTextCtrl alone can get you a lot of that stuff but not all of it even with custom elements.
Re: RichTextCtrl - cannot clear selected text. [message #58391 is a reply to message #58390] Mon, 16 May 2022 12:28 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1076
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello,

It seems that the fix introduce regression or maybe it behaves like this before. When you select text for example in TheIDE help and then right click on it. The selection is removed and copy text operation doesn't make much sense. Could you verify this?

Klugier


U++ - one framework to rule them all.
Re: RichTextCtrl - cannot clear selected text. [message #58392 is a reply to message #58391] Mon, 16 May 2022 13:07 Go to previous messageGo to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 220
Registered: June 2011
Experienced Member
I do seem to remember a problem similar to that although I haven't gotten latest yet. The problem was IIRC that focus is also lost if that copy popup is used so it deselects the text. My fix for it felt hacky - I had to check last control for IsPopup and if it was call WantFocus to bring it back but it was probably only a workable solution for my application.
Re: RichTextCtrl - cannot clear selected text. [message #58394 is a reply to message #58391] Mon, 16 May 2022 13:45 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Klugier wrote on Mon, 16 May 2022 12:28
Hello,

It seems that the fix introduce regression or maybe it behaves like this before. When you select text for example in TheIDE help and then right click on it. The selection is removed and copy text operation doesn't make much sense. Could you verify this?

Klugier


You are right, clearing selection in LostFocus is incosistent with behaviour of other widgets.

Back to drawing board: Reverted, RichTextView now has WhenLeftClick and ClearSelection. So with 2 RichTextCtrls it could look like this:

	a <<= "This is some text";
	b <<= "This is another text";
	
	a.WhenLeftClick = [=] { b.ClearSelection(); };
	b.WhenLeftClick = [=] { a.ClearSelection(); };


Mirek
Re: RichTextCtrl - cannot clear selected text. [message #58395 is a reply to message #58394] Mon, 16 May 2022 13:46 Go to previous message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 220
Registered: June 2011
Experienced Member
I had named mine ClearSelection too so I don't have to change anything. Very Happy

Thanks, Mirek.
Previous Topic: CtrlImg::Home() Icons
Next Topic: [FEATURE] Common horizontal scroll on Shift+mouse wheel
Goto Forum:
  


Current Time: Fri Apr 19 02:55:58 CEST 2024

Total time taken to generate the page: 0.03345 seconds