Skip to content

Commit cee74d4

Browse files
2Eagle2HelioGuilherme66
authored andcommitted
Grid editor fixes (#1846)
* fix contents Assistant to restore original cell value after hitting ESC * Wip fix win encoding (#1838) * Adds DEBUG for encoding, Chinese test OK in Linux * Fixed latin filenames or directories. * WIP try to fix non-unicode tags in python 2.7 * WIP fix latin chars tags * Clean up DEBUGs. All OK in Linux * Runs OK with python3 on Windows with directories with chinese or latin chars * fix bug when tooltip window from grid editor show on different tab after switch * improve contentassist handling * improve keyword information showing (work on single crtl hodl + hovering through grid cells) but the ctrl + m still persist * remove debug log * fix - pass RETURN key to contentAssist for selecting keyword from list * fix idle event return -1 error in some cases (window destroy events should be always skipped to properly disable all idle events / callLater events ) * fix contents Assistant to restore original cell value after hitting ESC * fix bug when tooltip window from grid editor show on different tab after switch * improve contentassist handling * improve keyword information showing (work on single crtl hodl + hovering through grid cells) but the ctrl + m still persist * remove debug log * fix - pass RETURN key to contentAssist for selecting keyword from list * fix idle event return -1 error in some cases (window destroy events should be always skipped to properly disable all idle events / callLater events ) * fix non invokable content assist while editing cell in grid editor
1 parent 06ae913 commit cee74d4

File tree

5 files changed

+39
-34
lines changed

5 files changed

+39
-34
lines changed

src/robotide/contrib/testrunner/testrunnerplugin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,13 @@ def disable(self):
216216
self.unsubscribe_all()
217217
self.unregister_actions()
218218

219-
def OnClose(self, evt):
219+
def OnClose(self, event):
220220
"""Shut down the running services and processes"""
221221
self._test_runner.kill_process()
222222
if self._process_timer:
223223
self._process_timer.Stop()
224224
self._test_runner.shutdown_server()
225+
event.Skip()
225226

226227
def OnAutoSaveCheckbox(self, evt):
227228
"""Called when the user clicks on the "Auto Save" checkbox"""

src/robotide/editor/contentassist.py

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,32 +49,28 @@ def set_row(self, row):
4949
def OnChar(self, event):
5050
# TODO: This might benefit from some cleanup
5151
keycode, control_down = event.GetKeyCode(), event.CmdDown()
52-
event.Skip() # DEBUG do it as soon we do not need it
53-
# print("DEBUG: Onchar before processing")
52+
# print("DEBUG: before processing" + str(keycode) + " + " + str(control_down))
5453
# Ctrl-Space handling needed for dialogs # DEBUG add Ctrl-m
5554
if (control_down or event.AltDown()) and keycode in (wx.WXK_SPACE, ord('m')):
5655
self.show_content_assist()
57-
return
58-
if keycode in [wx.WXK_UP, wx.WXK_DOWN, wx.WXK_PAGEUP, wx.WXK_PAGEDOWN]\
56+
elif keycode in [wx.WXK_UP, wx.WXK_DOWN, wx.WXK_PAGEUP, wx.WXK_PAGEDOWN]\
5957
and self._popup.is_shown():
6058
self._popup.select_and_scroll(keycode)
61-
return
6259
elif keycode == wx.WXK_RETURN and self._popup.is_shown():
6360
self.OnFocusLost(event)
64-
return
6561
elif keycode == wx.WXK_TAB:
6662
self.OnFocusLost(event, False)
6763
elif keycode == wx.WXK_ESCAPE and self._popup.is_shown():
6864
self._popup.hide()
69-
return
7065
elif self._popup.is_shown() and keycode < 256:
71-
self._populate_content_assist(event)
66+
wx.CallAfter(self._populate_content_assist)
67+
event.Skip()
7268
elif keycode in (ord('1'), ord('2'), ord('5')) and event.ControlDown() and not \
7369
event.AltDown():
7470
self.execute_variable_creator(list_variable=(keycode == ord('2')),
7571
dict_variable=(keycode == ord('5')))
76-
# print("DEBUG: Onchar before leaving")
77-
# event.Skip() # DEBUG Move up
72+
else:
73+
event.Skip()
7874

7975
def execute_variable_creator(self, list_variable=False, dict_variable=False):
8076
from_, to_ = self.GetSelection()
@@ -99,9 +95,9 @@ def OnFocusLost(self, event, set_value=True):
9995
event.Skip()
10096
return
10197
if self.gherkin_prefix:
102-
value = self.gherkin_prefix + self._popup.get_value() or ""
98+
value = self.gherkin_prefix + self._popup.get_value() or self.GetValue()
10399
else:
104-
value =self._popup.get_value() or ""
100+
value = self._popup.get_value() or self.GetValue()
105101
if set_value and value:
106102
self.SetValue(value)
107103
self.SetInsertionPoint(len(value)) # DEBUG was self.Value
@@ -121,19 +117,8 @@ def show_content_assist(self):
121117
if self._populate_content_assist():
122118
self._show_content_assist()
123119

124-
def _populate_content_assist(self, event=None):
120+
def _populate_content_assist(self):
125121
value = self.GetValue()
126-
if event is not None:
127-
if event.GetKeyCode() == wx.WXK_BACK:
128-
value = value[:-1]
129-
elif event.GetKeyCode() == wx.WXK_DELETE:
130-
pos = self.GetInsertionPoint()
131-
value = value[:pos] + value[pos + 1:]
132-
elif event.GetKeyCode() == wx.WXK_ESCAPE:
133-
self.hide()
134-
return False
135-
else:
136-
value += unichr(event.GetRawKeyCode())
137122
(self.gherkin_prefix, value) = self._remove_bdd_prefix(value)
138123
return self._popup.content_assist_for(value, row=self._row)
139124

@@ -386,6 +371,9 @@ def _select_and_scroll(self, selection):
386371
self._selection = selection
387372
self._list.Select(self._selection)
388373
self._list.EnsureVisible(self._selection)
374+
value = self.get_value()
375+
if value:
376+
self._parent.SetValue(value)
389377

390378
def hide(self):
391379
self._selection = -1

src/robotide/editor/kweditor.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,11 @@ def OnKeyDown(self, event):
502502
_iscelleditcontrolshown = self.IsCellEditControlShown()
503503

504504
keycode, control_down = event.GetKeyCode(), event.CmdDown()
505-
event.Skip() # DEBUG seen this skip as soon as possible
506-
if keycode == ord('M') and \
507-
(control_down or event.AltDown()): # keycode == wx.WXK_CONTROL
508-
self._show_cell_information()
505+
# print("DEBUG: key pressed " + str(keycode) + " + " + str(control_down))
506+
# event.Skip() # DEBUG seen this skip as soon as possible
507+
if keycode == wx.WXK_CONTROL or \
508+
(keycode == ord('M') and (control_down or event.AltDown())): # keycode == wx.WXK_CONTROL
509+
self.show_cell_information()
509510
elif keycode == ord('C') and control_down:
510511
# print("DEBUG: captured Control-C\n")
511512
self.OnCopy(event)
@@ -519,15 +520,18 @@ def OnKeyDown(self, event):
519520
self.OnSelectAll(event)
520521
elif event.AltDown() and keycode in [wx.WXK_DOWN, wx.WXK_UP]:
521522
self._move_rows(keycode)
523+
event.Skip()
522524
elif event.AltDown() and keycode == wx.WXK_RETURN:
523525
self._move_cursor_down(event)
526+
event.Skip()
524527
elif keycode == wx.WXK_WINDOWS_MENU:
525528
self.OnCellRightClick(event)
526529
elif keycode in [wx.WXK_RETURN, wx.WXK_BACK]:
527530
if not _iscelleditcontrolshown:
528531
self._move_grid_cursor(event, keycode)
529532
else:
530533
self.save()
534+
event.Skip()
531535
elif (control_down or event.AltDown()) and \
532536
keycode == wx.WXK_SPACE: # Avoid Mac CMD
533537
self._open_cell_editor_with_content_assist()
@@ -545,14 +549,14 @@ def OnKeyDown(self, event):
545549
elif control_down and keycode == ord('B'):
546550
self._navigate_to_matching_user_keyword(
547551
self.GetGridCursorRow(), self.GetGridCursorCol())
548-
# else:
549-
# event.Skip()
552+
else:
553+
event.Skip()
550554

551555
def OnGoToDefinition(self, event):
552556
self._navigate_to_matching_user_keyword(
553557
self.GetGridCursorRow(), self.GetGridCursorCol())
554558

555-
def _show_cell_information(self):
559+
def show_cell_information(self):
556560
cell = self.cell_under_cursor
557561
value = self._cell_value(cell)
558562
if value:
@@ -876,6 +880,7 @@ def BeginEdit(self, row, col, grid):
876880
self._tc.SetSize((-1, self._height))
877881
self._tc.set_row(row)
878882
self._original_value = grid.GetCellValue(row, col)
883+
self._tc.SetValue(self._original_value)
879884
self._grid = grid
880885
self._tc.SetInsertionPointEnd()
881886
self._tc.SetFocus()

src/robotide/editor/popupwindow.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ def _detach(self, event):
5757
event.Skip()
5858

5959
def show_at(self, position):
60-
if not self.IsShown():
60+
if self.GetPosition() != position:
6161
self.SetPosition(position)
62+
if not self.IsShown():
6263
self.Show()
6364

6465
def hide(self, event=None):

src/robotide/editor/tooltips.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def __init__(self, grid):
2727
self._grid = grid
2828
self._tooltip_timer = wx.Timer(grid.GetGridWindow())
2929
grid.GetGridWindow().Bind(wx.EVT_WINDOW_DESTROY, self.OnGridDestroy)
30+
grid.GetGridWindow().Bind(wx.EVT_KILL_FOCUS, self.OnGridFocusLost)
3031
grid.GetGridWindow().Bind(wx.EVT_MOTION, self.OnMouseMotion)
3132
grid.GetGridWindow().Bind(wx.EVT_TIMER, self.OnShowToolTip)
3233
grid.Bind(wx.grid.EVT_GRID_EDITOR_HIDDEN, self.OnGridEditorHidden)
@@ -35,9 +36,18 @@ def OnGridDestroy(self, event):
3536
self._tooltip_timer.Stop()
3637
event.Skip()
3738

39+
def OnGridFocusLost(self, event):
40+
self._tooltip_timer.Stop()
41+
event.Skip()
42+
3843
def OnMouseMotion(self, event):
3944
self._hide_tooltip()
40-
self._start_tooltip_timer()
45+
if event.CmdDown():
46+
self._tooltip_timer.Stop()
47+
self._grid.show_cell_information()
48+
else:
49+
self._information_popup.hide()
50+
self._start_tooltip_timer()
4151
event.Skip()
4252

4353
def _start_tooltip_timer(self):

0 commit comments

Comments
 (0)