User forums > General (but related to Code::Blocks)

Using wxTextCtrl::Remove()

(1/1)

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.


--- Code: ---void MainFrame::OnEditDelete(wxCommandEvent& event)
{
long int *begin, *end;

m_pTextCtrl->GetSelection(begin, end);

m_pTextCtrl->Remove((long int)begin, (long int)end);
}

--- End code ---

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.


--- Code: ---void MainFrame::OnEditDelete(wxCommandEvent& event)
{
long int *begin, *end;

m_pTextCtrl->GetSelection(begin, end);

m_pTextCtrl->Remove((long int)begin, (long int)end);
}

--- End code ---

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.

--- End quote ---

Your code is wrong. You have declared two pointer to ints that point nowhere (garbage).
Try this:


--- Code: ---void MainFrame::OnEditDelete(wxCommandEvent& event)
{
long int begin, end;

m_pTextCtrl->GetSelection(&begin, &end);

m_pTextCtrl->Remove(begin, end);
}

--- End code ---

sethjackson:
DOH, DOH, DOH.  :oops:

Am I an idiot or what?

Thanks Yiannis.

Navigation

[0] Message Index

Go to full version