I am making a C++ wxWidgets project, and I can't seem to clear it when I click inside a…
- User
I am making a C++ wxWidgets project, and I can't seem to clear it when I click inside a table created using BeginTable(). The only way to clear it, is if I manually click outside the table and then call the clear method. I tried many ways to get outside the table by code but it can't get out.
What I tried:
richTextChatBox->SetInsertionPoint(0); wxRichTextRange fullRange(0, richTextChatBox->GetLastPosition()); richTextChatBox->Delete(fullRange); textCtrlChatInput->SetFocus(); // focusing on other control, this just make another cursor in the other control but I can still see the cursor inside the table richTextChatBox->SelectAll(); richTextChatBox->DeleteSelection(); richTextChatBox->Clear();
Nothing worked! What can I do about this?
- Assistant
- User
Ok this work better but still doesn't fully work. I have a table of two columns, If I place the cursor in the first column, the second column so it moves to the right and delete that part but doesn't get out of the table. If I select the last column, it works correctly.
- Assistant
- User
The last code works even worse than the previous one, it doesn't even get out of the first column unlike previous code
- Assistant
- User
Nope this code can't get out either, so it deletes the content of the cell instead.
- Assistant
- User
Nope, it happens the same as the two last codes, only deletes the current cell but not get out of the table, the only one that did that was the first code
- Assistant
- User
OK I found out a way to do it, just using MoveRight(100) and then it goes outside. Is there a way to do this without using a hardcoded number?
void FrameMain::ClearChatBox() { richTextChatBox->SetFocus();
// Force the caret to move to the end of the document long lastPos = richTextChatBox->GetLastPosition(); richTextChatBox->SetInsertionPoint(lastPos); // Ensure we are out of any table context // (This ensures we’re outside any embedded objects, such as tables) while (richTextChatBox->GetCaretPosition() < lastPos) { long currentChar = richTextChatBox->GetCaretPosition(); richTextChatBox->MoveRight(100); if (richTextChatBox->GetCaretPosition() == currentChar) { break; // Break if the caret doesn’t move (end of document) } } // Perform the clearing operations richTextChatBox->SelectAll(); richTextChatBox->DeleteSelection();}
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.