From 6dad3c779831429e457fb048b3eff872ed6a92db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Thu, 12 Sep 2019 10:28:56 +0200 Subject: [PATCH] libtools/ToolText.py: ignore non-printable key events. --- libtools/ToolText.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libtools/ToolText.py b/libtools/ToolText.py index 5f0230c..f32179e 100644 --- a/libtools/ToolText.py +++ b/libtools/ToolText.py @@ -5,7 +5,7 @@ # from Tool import Tool -import wx +import string, wx class ToolText(Tool): name = "Text" @@ -13,7 +13,10 @@ class ToolText(Tool): # # onKeyboardEvent(self, brushColours, brushSize, canvas, dispatchFn, eventDc, keyChar, keyModifiers, mapPoint, viewRect) def onKeyboardEvent(self, brushColours, brushSize, canvas, dispatchFn, eventDc, keyChar, keyModifiers, mapPoint, viewRect): - if keyModifiers in (wx.MOD_NONE, wx.MOD_SHIFT): + if (ord(keyChar) != wx.WXK_NONE) \ + and (not keyChar in set("\t\n\v\f\r")) \ + and ((ord(keyChar) >= 32) if ord(keyChar) < 127 else True) \ + and (keyModifiers in (wx.MOD_NONE, wx.MOD_SHIFT)): rc, dirty = True, True if self.textPos == None: self.textPos = list(mapPoint)