Author Topic: Using wxTextCtrl::Remove()  (Read 4829 times)

sethjackson

  • Guest
Using wxTextCtrl::Remove()
« 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: [Select]
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.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Using wxTextCtrl::Remove()
« Reply #1 on: October 05, 2005, 08:49:51 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: [Select]
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:

Code: [Select]
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

  • Guest
Re: Using wxTextCtrl::Remove()
« Reply #2 on: October 05, 2005, 06:36:29 pm »
DOH, DOH, DOH.  :oops:

Am I an idiot or what?

Thanks Yiannis.