0

For testing purposes, I'm trying to print in the console everything that I write in a RichTextCtrl. However, it isn't working. Here is the way I wrote the binding for the RichTextCtrl, called textArea:

self.textArea.Bind( wx.EVT_KEY_DOWN, self.syntaxColoring_C )

And here is the event handler:

def syntaxColoring_C( self, event ):
    print self.textArea.GetValue()

However, when I type something, only a blank line is printed in the console, and nothing appears written in the RichTextCtrl. What am I doing wrong? Thanks in advance.

1
  • I was able to solve the problem by chaning the first given line to self.textArea.Bind( wx.EVT_KEY_UP, self.syntaxColoring_C, self.textArea ), although I'm not sure it is perfectly correct. Commented May 6, 2015 at 1:24

1 Answer 1

1

This can be corrected by adding event.Skip() in your event handling.

def syntaxColoring_C(self,event):
    print self.textArea.GetValue()
    event.Skip()

Quoting from This link,

You’ll notice that I also call “event.Skip” at the end. Iif you don’t call Skip, then the key will “eaten” and there won’t be a corresponding char event. This won’t matter on a button, but you might care in a text control as char events are the proper way of catching upper and lower case, accents, umlauts and the like.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.