From a5a9dc08772aa947f8f50950b341b05e95b3faaf Mon Sep 17 00:00:00 2001 From: Jonah Jolley Date: Thu, 21 Feb 2019 00:28:21 -0700 Subject: [PATCH 1/3] Adding support for ctrl+backspace in searchbars --- gui/builtinMarketBrowser/pfSearchBox.py | 9 ++++++++- gui/builtinShipBrowser/navigationPanel.py | 7 +++++-- gui/utils/helpers_wxPython.py | 20 ++++++++++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/gui/builtinMarketBrowser/pfSearchBox.py b/gui/builtinMarketBrowser/pfSearchBox.py index 8d0871f6a..38706a34d 100644 --- a/gui/builtinMarketBrowser/pfSearchBox.py +++ b/gui/builtinMarketBrowser/pfSearchBox.py @@ -2,6 +2,7 @@ import wx import gui.utils.color as colorUtils import gui.utils.draw as drawUtils +from gui.utils.helpers_wxPython import HandleCtrlBackspace SearchButton, EVT_SEARCH_BTN = wx.lib.newevent.NewEvent() CancelButton, EVT_CANCEL_BTN = wx.lib.newevent.NewEvent() @@ -55,7 +56,7 @@ class PFSearchBox(wx.Window): self.EditBox.Bind(wx.EVT_SET_FOCUS, self.OnEditSetFocus) self.EditBox.Bind(wx.EVT_KILL_FOCUS, self.OnEditKillFocus) - + self.EditBox.Bind(wx.EVT_KEY_DOWN, self.OnKeyPress) self.EditBox.Bind(wx.EVT_TEXT, self.OnText) self.EditBox.Bind(wx.EVT_TEXT_ENTER, self.OnTextEnter) @@ -83,6 +84,12 @@ class PFSearchBox(wx.Window): self.Clear() event.Skip() + def OnKeyPress(self, event): + if event.RawControlDown() and event.GetKeyCode() == wx.WXK_BACK: + HandleCtrlBackspace(self.EditBox) + else: + event.Skip() + def Clear(self): self.EditBox.Clear() # self.EditBox.ChangeValue(self.descriptiveText) diff --git a/gui/builtinShipBrowser/navigationPanel.py b/gui/builtinShipBrowser/navigationPanel.py index 204802c45..e7f339260 100644 --- a/gui/builtinShipBrowser/navigationPanel.py +++ b/gui/builtinShipBrowser/navigationPanel.py @@ -11,6 +11,7 @@ import gui.utils.fonts as fonts from .events import FitSelected, SearchSelected, ImportSelected, Stage1Selected, Stage2Selected, Stage3Selected from gui.bitmap_loader import BitmapLoader from service.fit import Fit +from gui.utils.helpers_wxPython import HandleCtrlBackspace pyfalog = Logger(__name__) @@ -72,7 +73,7 @@ class NavigationPanel(SFItem.SFBrowserItem): # self.BrowserSearchBox.Bind(wx.EVT_TEXT_ENTER, self.OnBrowserSearchBoxEnter) # self.BrowserSearchBox.Bind(wx.EVT_KILL_FOCUS, self.OnBrowserSearchBoxLostFocus) - self.BrowserSearchBox.Bind(wx.EVT_KEY_DOWN, self.OnBrowserSearchBoxEsc) + self.BrowserSearchBox.Bind(wx.EVT_KEY_DOWN, self.OnBrowserSearchBoxKeyPress) self.BrowserSearchBox.Bind(wx.EVT_TEXT, self.OnScheduleSearch) self.SetMinSize(size) @@ -103,9 +104,11 @@ class NavigationPanel(SFItem.SFBrowserItem): def OnBrowserSearchBoxLostFocus(self, event): self.BrowserSearchBox.Show(False) - def OnBrowserSearchBoxEsc(self, event): + def OnBrowserSearchBoxKeyPress(self, event): if event.GetKeyCode() == wx.WXK_ESCAPE: self.BrowserSearchBox.Show(False) + elif event.RawControlDown() and event.GetKeyCode() == wx.WXK_BACK: + HandleCtrlBackspace(self.BrowserSearchBox) else: event.Skip() diff --git a/gui/utils/helpers_wxPython.py b/gui/utils/helpers_wxPython.py index e0f9d0ae0..26f98c35d 100644 --- a/gui/utils/helpers_wxPython.py +++ b/gui/utils/helpers_wxPython.py @@ -6,3 +6,23 @@ def YesNoDialog(question='Are you sure you want to do this?', caption='Yes or no result = dlg.ShowModal() == wx.ID_YES dlg.Destroy() return result + + +def HandleCtrlBackspace(textControl): + """ + Handles the behavior of Windows ctrl+space + deletes everything from the cursor to the left, + up to the next whitespace. + """ + curPos = textControl.GetInsertionPoint() + searchText = textControl.GetValue() + foundChar = False + for startIndex in range(curPos, -1, -1): + if startIndex - 1 < 0: + break + if searchText[startIndex - 1] != " ": + foundChar = True + elif foundChar: + break + textControl.Remove(startIndex, curPos) + textControl.SetInsertionPoint(startIndex) \ No newline at end of file From 4dc70dad3be9f5dd8aa487e525eb682fd872e0ce Mon Sep 17 00:00:00 2001 From: blitzmann Date: Sun, 24 Feb 2019 17:58:55 -0500 Subject: [PATCH 2/3] Apply CTRL+Backspace fix for fitting Notes text box --- gui/builtinAdditionPanes/notesView.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gui/builtinAdditionPanes/notesView.py b/gui/builtinAdditionPanes/notesView.py index 35a75b5a8..a4a807509 100644 --- a/gui/builtinAdditionPanes/notesView.py +++ b/gui/builtinAdditionPanes/notesView.py @@ -4,6 +4,7 @@ import wx from service.fit import Fit import gui.globalEvents as GE import gui.mainFrame +from gui.utils.helpers_wxPython import HandleCtrlBackspace class NotesView(wx.Panel): @@ -17,9 +18,16 @@ class NotesView(wx.Panel): self.SetSizer(mainSizer) self.mainFrame.Bind(GE.FIT_CHANGED, self.fitChanged) self.Bind(wx.EVT_TEXT, self.onText) + self.editNotes.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) self.saveTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.delayedSave, self.saveTimer) + def OnKeyDown(self, event): + if event.RawControlDown() and event.GetKeyCode() == wx.WXK_BACK: + HandleCtrlBackspace(self.editNotes) + else: + event.Skip() + def fitChanged(self, event): sFit = Fit.getInstance() fit = sFit.getFit(event.fitID) From f68ee81634d8693941f77c709e2b9af855620cab Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Mon, 25 Feb 2019 09:26:35 +0300 Subject: [PATCH 3/3] Change stats window size for gtk --- gui/itemStats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/itemStats.py b/gui/itemStats.py index 50a02f065..8ff858402 100644 --- a/gui/itemStats.py +++ b/gui/itemStats.py @@ -91,7 +91,7 @@ class ItemStatsDialog(wx.Dialog): self.SetMinSize((300, 200)) if "wxGTK" in wx.PlatformInfo: # GTK has huge tab widgets, give it a bit more room - self.SetSize((630, 550)) + self.SetSize((640, 620)) else: self.SetSize((550, 500)) # self.SetMaxSize((500, -1))