Hi, I have written a nice little editor using the RichTextCtrl, and so far everything is working fine, however, for some reason the delete key does not work as expected.

If I select something and hit delete then the selection is removed, but if I click anywhere in the text and hit delete, the text remains unchanged (Instead of being 'sucked' into the cursor).

Anyone have any ideas?

Cheers

Max

Yeah i got the same issue when i did a program using a richtextctrl.
I fixed it by binding the delete key to an event where i called something along the lines of

self.text.SetSelection(self.text.GetCursor()[0],self.text.GetCursor()[1]+1)
self.text.DeleteSelection()

I remember having to bind it to a wx.EVT_KEY_DOWN event because i could not find one for DELETE specifically so then i just checked in the method to see if it was the delete key and then if it was the method continued to run.

Hey Paul, thanks.

But it didn't work. I already bind to EVT_RICHTEXT_CHARACTER (Delete doesn't work with or without it), but no matter which event I use, the delete key is not doing anything, and that includes firing these events.

I also found and tried the EVT_RICHTEXT_DELETE, which picks up backspace quite nicely, but again, the Delete key doesn't even fire the event. Using EVT_KEY_DOWN works for everything on the keyboard except the delete key, and thats right up to the point where the Delete key doesn't fire the event!

And yes, the Delete key is fine!

And here's the really weird thing: If I make sure that NumLock is in the right place, the Del key on the keypad works exactly as its supposed to!

I just don't know where to go with this next, and I'm at the point of giving up and using the keypad Del key instead, as much as it annoys me to do so.

Got any ideas?

Max

Well my next and last step would be to go to the wxpython mailing list and see if anyone there can help, i find if there is ever a problem in wx that cannot be fixed, that the mailing list really does the trick.

Cheers Paul, Ill have to do some more hunting about.

Max

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.