Fixed a few things in tootDialog

This commit is contained in:
Manuel Cortez 2022-11-11 17:32:31 -06:00
parent 0d1d4c887d
commit 803f5fbe89
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790

View File

@ -9,6 +9,7 @@ class Toot(wx.Dialog):
toot_label = wx.StaticText(self, wx.ID_ANY, caption) toot_label = wx.StaticText(self, wx.ID_ANY, caption)
toot_sizer.Add(toot_label, 0, 0, 0) toot_sizer.Add(toot_label, 0, 0, 0)
self.text = wx.TextCtrl(self, wx.ID_ANY, text, style=wx.TE_MULTILINE) self.text = wx.TextCtrl(self, wx.ID_ANY, text, style=wx.TE_MULTILINE)
self.Bind(wx.EVT_CHAR_HOOK, self.handle_keys, self.text)
self.text.SetMinSize((350, -1)) self.text.SetMinSize((350, -1))
toot_sizer.Add(self.text, 0, 0, 0) toot_sizer.Add(self.text, 0, 0, 0)
lists_sizer = wx.BoxSizer(wx.HORIZONTAL) lists_sizer = wx.BoxSizer(wx.HORIZONTAL)
@ -83,6 +84,14 @@ class Toot(wx.Dialog):
self.SetEscapeId(self.close.GetId()) self.SetEscapeId(self.close.GetId())
self.Layout() self.Layout()
def handle_keys(self, event: wx.Event, *args, **kwargs) -> None:
""" Allows to react to certain keyboard events from the text control. """
shift=event.ShiftDown()
if event.GetKeyCode() == wx.WXK_RETURN and shift==False and hasattr(self,'send'):
self.EndModal(wx.ID_OK)
else:
event.Skip()
def on_sensitivity_changed(self, *args, **kwargs): def on_sensitivity_changed(self, *args, **kwargs):
self.spoiler.Enable(self.sensitive.GetValue()) self.spoiler.Enable(self.sensitive.GetValue())