@@ -48,9 +48,13 @@ def tearDown(self):
4848 return
4949
5050
51- def _leftclickcell (self , row , col , ** kw ):
51+ def _clickcell (self , leftright , row , col , ** kw ):
5252 gp = self .panel .grid_parameters
53- eventtype = wx .grid .EVT_GRID_CELL_LEFT_CLICK .typeId
53+ assert leftright in ('left' , 'right' )
54+ if leftright == "left" :
55+ eventtype = wx .grid .EVT_GRID_CELL_LEFT_CLICK .typeId
56+ else :
57+ eventtype = wx .grid .EVT_GRID_CELL_RIGHT_CLICK .typeId
5458 kbd = {'kbd' : wx .KeyboardState (** kw )}
5559 # TODO: remove this after deprecations of wxpython 3
5660 if wx .VERSION [0 ] == 3 :
@@ -104,24 +108,37 @@ def test_onCellLeftClick(self):
104108 self .assertFalse (self .panel .mainFrame .altered )
105109 self .assertEqual ("0" , gp .GetCellValue (0 , 1 ))
106110 self .assertFalse (p .fixed )
107- self ._leftclickcell ( 0 , 1 )
111+ self ._clickcell ( "left" , 0 , 1 )
108112 self .assertEqual ("1" , gp .GetCellValue (0 , 1 ))
109113 self .assertTrue (p .fixed )
110114 self .assertTrue (self .panel .mainFrame .altered )
111- self ._leftclickcell ( 0 , 1 )
115+ self ._clickcell ( "left" , 0 , 1 )
112116 self .assertEqual ("0" , gp .GetCellValue (0 , 1 ))
113- self ._leftclickcell ( 0 , 1 , controlDown = True )
117+ self ._clickcell ( "left" , 0 , 1 , controlDown = True )
114118 self .assertEqual ("0" , gp .GetCellValue (0 , 1 ))
115- self ._leftclickcell ( 0 , 1 , shiftDown = True )
119+ self ._clickcell ( "left" , 0 , 1 , shiftDown = True )
116120 self .assertEqual ("0" , gp .GetCellValue (0 , 1 ))
117121 gp .SelectAll ()
118- self ._leftclickcell ( 0 , 1 )
122+ self ._clickcell ( "left" , 0 , 1 )
119123 self .assertEqual ("0" , gp .GetCellValue (0 , 1 ))
120124 gp .ClearSelection ()
121- self ._leftclickcell ( 0 , 1 )
125+ self ._clickcell ( "left" , 0 , 1 )
122126 self .assertEqual ("1" , gp .GetCellValue (0 , 1 ))
123127 return
124128
129+
130+ def test_onCellRightClick (self ):
131+ "Check right-click handling on the Parameters grid."
132+ # disable modal grid_parameters.PopupMenu
133+ gp = self .panel .grid_parameters
134+ gp .PopupMenu = lambda menu , pos : None
135+ try :
136+ self ._clickcell ("right" , 0 , 1 )
137+ finally :
138+ del gp .PopupMenu
139+ self .assertTrue (self .panel .did_popupIDs )
140+ return
141+
125142# End of class TestParametersPanel
126143
127144# ----------------------------------------------------------------------------
0 commit comments