1717from wx import grid
1818import json
1919from robotide .editor .cellrenderer import CellRenderer
20+ from robotide import context
2021
2122if wx .VERSION >= (3 , 0 , 3 , '' ): # DEBUG wxPhoenix
2223 from wx .grid import GridCellEditor
2526else :
2627 from wx .grid import PyGridCellEditor as GridCellEditor
2728
28- from robotide .context import IS_MAC
29+ from robotide .context import IS_MAC , IS_WINDOWS
2930from robotide .controller .ctrlcommands import ChangeCellValue , ClearArea , \
3031 PasteArea , DeleteRows , AddRows , CommentRows , InsertCells , DeleteCells , \
3132 UncommentRows , Undo , Redo , RenameKeywordOccurrences , ExtractKeyword , \
@@ -301,7 +302,7 @@ def OnInsertCells(self, event=None):
301302 # TODO remove below workaround for double actions
302303 if self ._counter == 1 :
303304 if self ._icells == (
304- self .selection .topleft , self .selection .bottomright ):
305+ self .selection .topleft , self .selection .bottomright ):
305306 self ._counter = 0
306307 self ._icells = None
307308 return
@@ -567,9 +568,10 @@ def OnKeyDown(self, event):
567568 keycode , control_down = event .GetKeyCode (), event .CmdDown ()
568569 # print("DEBUG: key pressed " + str(keycode) + " + " + str(control_down))
569570 # event.Skip() # DEBUG seen this skip as soon as possible
570- if keycode == wx .WXK_CONTROL or \
571- (keycode == ord ('M' ) and (control_down or event .AltDown ())): # keycode == wx.WXK_CONTROL
571+ if keycode != wx .WXK_SPACE and control_down or event .AltDown (): # keycode == wx.WXK_CONTROL
572572 self .show_cell_information ()
573+ if keycode == wx .WXK_SPACE and (control_down or event .AltDown ()): # Avoid Mac CMD
574+ self ._open_cell_editor_with_content_assist ()
573575 elif keycode == ord ('C' ) and control_down :
574576 # print("DEBUG: captured Control-C\n")
575577 self .OnCopy (event )
@@ -598,9 +600,6 @@ def OnKeyDown(self, event):
598600 self .save ()
599601 self ._move_grid_cursor (event , keycode )
600602 # event.Skip()
601- elif (control_down or event .AltDown ()) and \
602- keycode == wx .WXK_SPACE : # Avoid Mac CMD
603- self ._open_cell_editor_with_content_assist ()
604603 elif control_down and not event .AltDown () and \
605604 keycode in (ord ('1' ), ord ('2' ), ord ('5' )):
606605 self ._open_cell_editor_and_execute_variable_creator (
@@ -692,7 +691,6 @@ def _open_cell_editor_with_content_assist(self):
692691 celleditor = self .GetCellEditor (self .GetGridCursorCol (), row )
693692 celleditor .Show (True )
694693 wx .CallAfter (celleditor .show_content_assist )
695- # print("DEBUG: Called content assist %s\n" % self._show_cell_information())
696694
697695 def _open_cell_editor_and_execute_variable_creator (
698696 self , list_variable = False , dict_variable = False ):
@@ -927,7 +925,8 @@ def __init__(self, plugin, controller):
927925 self ._counter = 0
928926
929927 def show_content_assist (self , args = None ):
930- self ._tc .show_content_assist ()
928+ if self ._tc :
929+ self ._tc .show_content_assist ()
931930
932931 def execute_variable_creator (self , list_variable = False ,
933932 dict_variable = False ):
@@ -954,12 +953,14 @@ def SetHeight(self, height):
954953 def BeginEdit (self , row , col , grid ):
955954 self ._counter = 0
956955 self ._tc .SetSize ((- 1 , self ._height ))
956+ self ._tc .SetBackgroundColour (context .POPUP_BACKGROUND ) # DEBUG: We are now in Edit mode
957957 self ._tc .set_row (row )
958958 self ._original_value = grid .GetCellValue (row , col )
959959 self ._tc .SetValue (self ._original_value )
960960 self ._grid = grid
961961 self ._tc .SetInsertionPointEnd ()
962- # self._tc.SetFocus() # On Win 10 this breaks cell text selection
962+ if not IS_WINDOWS :
963+ self ._tc .SetFocus () # On Win 10 this breaks cell text selection
963964 # For this example, select the text # DEBUG nov_2017
964965 # self._tc.SetSelection(0, self._tc.GetLastPosition())
965966
@@ -989,8 +990,11 @@ def ApplyEdit(self, row, col, grid):
989990 self ._original_value = ''
990991 self ._tc .SetValue ('' )
991992 if wx .VERSION >= (3 , 0 , 2 , '' ): # DEBUG wxPhoenix
992- if self ._value or val == '' :
993+ if self ._value and val != '' : # DEBUG Fix #1967 crash when click other cell
993994 self ._grid .cell_value_edited (row , col , self ._value )
995+ else :
996+ self ._tc .hide ()
997+
994998
995999 def _get_value (self ):
9961000 suggestion = self ._tc .content_assist_value ()
0 commit comments