I'm trying to implement a delete function for this text editor I'm making (I'm doing this to learn about wxWidgets).
I want to have a delete function that works like notepad's. :) Basically if there is text selected and the user clicks Edit->Delete the
text editor deletes the text.
Anyways, Here is the code; it doesn't do anything.
void MainFrame::OnEditDelete(wxCommandEvent& event)
{
long int *begin, *end;
m_pTextCtrl->GetSelection(begin, end);
m_pTextCtrl->Remove((long int)begin, (long int)end);
}
I haven't posted the relevant event table entries or anything but it should be easy to understand.
I want to know if this is the correct way to do this. I'm assuming its not since it doesn't work.
I'm trying to implement a delete function for this text editor I'm making (I'm doing this to learn about wxWidgets).
I want to have a delete function that works like notepad's. :) Basically if there is text selected and the user clicks Edit->Delete the
text editor deletes the text.
Anyways, Here is the code; it doesn't do anything.
void MainFrame::OnEditDelete(wxCommandEvent& event)
{
long int *begin, *end;
m_pTextCtrl->GetSelection(begin, end);
m_pTextCtrl->Remove((long int)begin, (long int)end);
}
I haven't posted the relevant event table entries or anything but it should be easy to understand.
I want to know if this is the correct way to do this. I'm assuming its not since it doesn't work.
Your code is wrong. You have declared two pointer to ints that point nowhere (garbage).
Try this:
void MainFrame::OnEditDelete(wxCommandEvent& event)
{
long int begin, end;
m_pTextCtrl->GetSelection(&begin, &end);
m_pTextCtrl->Remove(begin, end);
}