I have a wxTextCtrl and I have the cursor move 4 spaces on tab key down. But if I have not typed anything the cursor does not move nor does text when I press tab.
self.editor = wx.TextCtrl(splitter, style = wx.TE_MULTILINE)
wx.EVT_KEY_DOWN(self.editor, self.on_key_down)
def on_key_down(self, e):
if e.GetKeyCode() == wx.WXK.TAB:
current = self.editor.GetInsertionPoint()
tab = current + 4
self.editor.SetInsertionPoint(tab)
else:
e.Skip()
If anyone could help me with getting the cursor to move even if I've not typed anything in front of the cursor and any text in front of the cursor.
Also I would like to get certain key words to change colour when typed. If anyone could help with that I would be very appreciative.
Try using WriteText:
def on_key_down(self, e):
if e.GetKeyCode() == wx.WXK_TAB:
tab = ' ' * 4
self.editor.WriteText(tab)
else:
e.Skip()