Fix up focus for ship browser, allowing space or enter to work to open up new stage
This commit is contained in:
@@ -56,6 +56,11 @@ class CategoryItem(SFBrowserItem):
|
||||
self.animTimer.Stop()
|
||||
self.Refresh()
|
||||
|
||||
def OnKeyUp(self, event):
|
||||
if event.GetKeyCode() in (32, 13): # space and enter
|
||||
self.selectCategory(event)
|
||||
event.Skip()
|
||||
|
||||
@staticmethod
|
||||
def OUT_QUAD(t, b, c, d):
|
||||
t = float(t)
|
||||
@@ -70,11 +75,13 @@ class CategoryItem(SFBrowserItem):
|
||||
def GetType(self):
|
||||
return 1
|
||||
|
||||
def MouseLeftUp(self, event):
|
||||
|
||||
def selectCategory(self, event):
|
||||
categoryID = self.categoryID
|
||||
wx.PostEvent(self.shipBrowser, Stage2Selected(categoryID=categoryID, back=False))
|
||||
|
||||
def MouseLeftUp(self, event):
|
||||
self.selectCategory(event)
|
||||
|
||||
def UpdateElementsPos(self, mdc):
|
||||
rect = self.GetRect()
|
||||
self.shipBmpx = self.padding
|
||||
|
||||
@@ -157,8 +157,8 @@ class FitItem(SFItem.SFBrowserItem):
|
||||
notes = u'─' * 20 + u"\nNotes: {}\n".format(self.notes[:197] + '...' if len(self.notes) > 200 else self.notes)
|
||||
self.SetToolTip(wx.ToolTip(u'{}\n{}{}\n{}'.format(self.shipName, notes, u'─' * 20, self.shipTrait)))
|
||||
|
||||
def OnKeyDown(self, event):
|
||||
if event.GetKeyCode() == 32: # space
|
||||
def OnKeyUp(self, event):
|
||||
if event.GetKeyCode() in (32, 13): # space and enter
|
||||
self.selectFit(event)
|
||||
event.Skip()
|
||||
|
||||
|
||||
@@ -67,11 +67,11 @@ class NavigationPanel(SFItem.SFBrowserItem):
|
||||
w, h = size
|
||||
self.BrowserSearchBox = wx.TextCtrl(self, wx.ID_ANY, "", wx.DefaultPosition,
|
||||
(-1, h - 2 if 'wxGTK' in wx.PlatformInfo else -1),
|
||||
wx.TE_PROCESS_ENTER | (wx.BORDER_NONE if 'wxGTK' in wx.PlatformInfo else 0))
|
||||
(wx.BORDER_NONE if 'wxGTK' in wx.PlatformInfo else 0))
|
||||
self.BrowserSearchBox.Show(False)
|
||||
|
||||
self.BrowserSearchBox.Bind(wx.EVT_TEXT_ENTER, self.OnBrowserSearchBoxEnter)
|
||||
self.BrowserSearchBox.Bind(wx.EVT_KILL_FOCUS, self.OnBrowserSearchBoxLostFocus)
|
||||
#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_TEXT, self.OnScheduleSearch)
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ class SFBrowserItem(wx.Window):
|
||||
self.Bind(wx.EVT_PAINT, self.OnPaint)
|
||||
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
|
||||
self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
|
||||
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
|
||||
self.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
|
||||
|
||||
|
||||
if "wxMSW" in wx.PlatformInfo:
|
||||
@@ -296,7 +296,7 @@ class SFBrowserItem(wx.Window):
|
||||
def OnEraseBackground(self, event):
|
||||
pass
|
||||
|
||||
def OnKeyDown(self, event):
|
||||
def OnKeyUp(self, event):
|
||||
pass
|
||||
|
||||
def MouseLeftUp(self, event):
|
||||
|
||||
@@ -120,6 +120,11 @@ class ShipItem(SFItem.SFBrowserItem):
|
||||
self.animTimer.Stop()
|
||||
self.Refresh()
|
||||
|
||||
def OnKeyUp(self, event):
|
||||
if event.GetKeyCode() in (32, 13): # space and enter
|
||||
self.selectShip(event)
|
||||
event.Skip()
|
||||
|
||||
@staticmethod
|
||||
def OUT_QUAD(t, b, c, d):
|
||||
t = float(t)
|
||||
@@ -134,7 +139,7 @@ class ShipItem(SFItem.SFBrowserItem):
|
||||
def GetType(self):
|
||||
return 2
|
||||
|
||||
def MouseLeftUp(self, event):
|
||||
def selectShip(self, event):
|
||||
if self.tcFitName.IsShown():
|
||||
self.tcFitName.Show(False)
|
||||
self.newBtn.SetBitmap(self.newBmp)
|
||||
@@ -146,6 +151,9 @@ class ShipItem(SFItem.SFBrowserItem):
|
||||
else:
|
||||
self.newBtnCB()
|
||||
|
||||
def MouseLeftUp(self, event):
|
||||
self.selectShip(event)
|
||||
|
||||
def newBtnCB(self):
|
||||
if self.tcFitName.IsShown():
|
||||
self.tcFitName.Show(False)
|
||||
|
||||
@@ -54,11 +54,12 @@ class ShipBrowser(wx.Panel):
|
||||
|
||||
mainSizer = wx.BoxSizer(wx.VERTICAL)
|
||||
|
||||
self.navpanel = NavigationPanel(self)
|
||||
mainSizer.Add(self.navpanel, 0, wx.EXPAND)
|
||||
|
||||
self.lpane = PFWidgetsContainer(self)
|
||||
layout = wx.HORIZONTAL
|
||||
|
||||
self.navpanel = NavigationPanel(self)
|
||||
mainSizer.Add(self.navpanel, 0, wx.EXPAND)
|
||||
self.raceselect = RaceSelector(self, layout=layout, animate=False)
|
||||
container = wx.BoxSizer(wx.VERTICAL if layout == wx.HORIZONTAL else wx.HORIZONTAL)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user