News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Using wxTextCtrl::Remove()

Started by sethjackson, October 05, 2005, 01:09:55 AM

Previous topic - Next topic

sethjackson

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.

mandrav

Quote from: sethjackson on October 05, 2005, 01:09:55 AM
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);
}

Be patient!
This bug will be fixed soon...

sethjackson

DOH, DOH, DOH.  :oops:

Am I an idiot or what?

Thanks Yiannis.