@@ -43,15 +43,10 @@ def __init__( self, parent ):
4343 self .helpText = wx .StaticText ( self , wx .ID_ANY , help , wx .DefaultPosition , wx .DefaultSize , wx .ALIGN_CENTRE )
4444 helpSizer .Add ( self .helpText , 1 , wx .ALL , 5 )
4545
46- self .FitDNDPopupMenu = wx .Menu ()
47-
4846 self .options = ["Fleet" , "Wing" , "Squad" ]
4947
5048 self .fleet = {}
5149 for id , option in enumerate (self .options ):
52- item = self .FitDNDPopupMenu .Append (- 1 , option )
53- # We bind it to the mainFrame because it may be called from either this class or from FitItem via shipBrowser
54- self .mainFrame .Bind (wx .EVT_MENU , self .OnPopupItemSelected , item )
5550
5651 # set content for each commander
5752 self .fleet [id ] = {}
@@ -61,6 +56,8 @@ def __init__( self, parent ):
6156 self .fleet [id ]['chChar' ] = wx .Choice ( self , wx .ID_ANY , wx .DefaultPosition , wx .DefaultSize , [] )
6257 self .fleet [id ]['fitSizer' ] = wx .BoxSizer ( wx .VERTICAL )
6358
59+ self .FitDNDPopupMenu = self .buildBoostermenu ()
60+
6461 contentFGSizer = wx .FlexGridSizer ( 5 , 3 , 0 , 0 )
6562 contentFGSizer .AddGrowableCol ( 1 )
6663 contentFGSizer .SetFlexibleDirection ( wx .BOTH )
@@ -130,6 +127,15 @@ def __init__( self, parent ):
130127 self .RefreshBoosterFits ()
131128 self .RefreshCharacterList ()
132129
130+ def buildBoostermenu (self ):
131+ menu = wx .Menu ()
132+
133+ for id , option in enumerate (self .options ):
134+ item = menu .Append (- 1 , option )
135+ # We bind it to the mainFrame because it may be called from either this class or from FitItem via shipBrowser
136+ self .mainFrame .Bind (wx .EVT_MENU , self .OnPopupItemSelected , item )
137+ return menu
138+
133139 def OnEnterWindow (self , event ):
134140 obj = event .GetEventObject ()
135141 obj .SetCursor (wx .StockCursor (wx .CURSOR_HAND ))
@@ -371,7 +377,7 @@ def handleDrag(self, type, fitID):
371377 def OnPopupItemSelected (self , event ):
372378 ''' Fired when booster popup item is selected '''
373379 # Get menu selection ID via self.options
374- menuItem = self . FitDNDPopupMenu .FindItemById (event .GetId ())
380+ menuItem = event . EventObject .FindItemById (event .GetId ())
375381 type = self .options .index (menuItem .GetText ())
376382
377383 if self .draggedFitID :
0 commit comments