libtools/ToolText.py: ignore non-printable key events.

This commit is contained in:
Lucio Andrés Illanes Albornoz 2019-09-12 10:28:56 +02:00
parent 133f99371b
commit 58765e187c

View File

@ -5,7 +5,7 @@
# #
from Tool import Tool from Tool import Tool
import wx import string, wx
class ToolText(Tool): class ToolText(Tool):
name = "Text" name = "Text"
@ -13,7 +13,10 @@ class ToolText(Tool):
# #
# onKeyboardEvent(self, brushColours, brushSize, canvas, dispatchFn, eventDc, keyChar, keyModifiers, mapPoint, viewRect) # onKeyboardEvent(self, brushColours, brushSize, canvas, dispatchFn, eventDc, keyChar, keyModifiers, mapPoint, viewRect)
def 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 rc, dirty = True, True
if self.textPos == None: if self.textPos == None:
self.textPos = list(mapPoint) self.textPos = list(mapPoint)