If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
evstevemd
Part Of The Furniture
Posts: 2409 Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Post
by evstevemd » Tue Aug 13, 2019 6:14 am
I do replacement of text using WriteText and since it removes multi cursors, I need to store their positions in the std::vector<int> as shown below. Then after write text is done I want to restore multi cursors but It does not work
Code: Select all
//saving
std::vector<int> carets;
for(int i = 0; i < editor->GetSelections(); ++i) {
int caret = editor->GetSelectionNCaret(i);
carets.push_back(caret);
}
//restoring
for(int i = 0; i < carets.size(); i++) {
if(i == 0)
editor->SetSelection(carets[i], carets[i]);
else
editor->AddSelection(carets[i], carets[i]);
}
I have tried so many things that I cannot remember. This is my latest trial that failed also!
Chief Justice : We have trouble dear citizens!
Citizens : What it is his honor?
Chief Justice :Our president is an atheist, who will he swear to?
doublemax
Moderator
Posts: 19160 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Tue Aug 13, 2019 3:56 pm
Code: Select all
editor->SetSelection(carets[i], carets[i]);
I don't know anything about wxSTC, but shouldn't that be:
Code: Select all
editor->SetSelection(i, carets[i]);
Use the source, Luke!
evstevemd
Part Of The Furniture
Posts: 2409 Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Post
by evstevemd » Thu Aug 15, 2019 6:43 am
Hi,
doublemax wrote: ↑ Tue Aug 13, 2019 3:56 pm
Code: Select all
editor->SetSelection(carets[i], carets[i]);
I don't know anything about wxSTC, but shouldn't that be:
Code: Select all
editor->SetSelection(i, carets[i]);
I have tested many combination and I don't remember anymore if that was one of those. Let me try that out and see
Chief Justice : We have trouble dear citizens!
Citizens : What it is his honor?
Chief Justice :Our president is an atheist, who will he swear to?
Kvaz1r
Super wx Problem Solver
Posts: 357 Joined: Tue Jun 07, 2016 1:07 pm
Post
by Kvaz1r » Thu Aug 15, 2019 7:06 am
How exactly it didn't work? Carets are not restored or they restored on wrong positions?
evstevemd
Part Of The Furniture
Posts: 2409 Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Post
by evstevemd » Mon Aug 19, 2019 11:52 am
Kvaz1r wrote: ↑ Thu Aug 15, 2019 7:06 am
How exactly it didn't work? Carets are not restored or they restored on wrong positions?
Only last caret was restored. Others were lost. Am yet to apply DM solution!
Chief Justice : We have trouble dear citizens!
Citizens : What it is his honor?
Chief Justice :Our president is an atheist, who will he swear to?
evstevemd
Part Of The Furniture
Posts: 2409 Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Post
by evstevemd » Tue Aug 20, 2019 8:47 pm
doublemax wrote: ↑ Tue Aug 13, 2019 3:56 pm
Code: Select all
editor->SetSelection(carets[i], carets[i]);
I don't know anything about wxSTC, but shouldn't that be:
Code: Select all
editor->SetSelection(i, carets[i]);
I tried it does not work. I can't figure out what I am doing wrong
Chief Justice : We have trouble dear citizens!
Citizens : What it is his honor?
Chief Justice :Our president is an atheist, who will he swear to?