author | laurent |
Fri, 18 Nov 2011 17:39:12 +0100 | |
changeset 590 | b2442bb10c0b |
parent 577 | 9dbb79722fbc |
child 600 | 7db729686416 |
permissions | -rw-r--r-- |
577
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
3 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
4 |
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
5 |
#based on the plcopen standard. |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
6 |
# |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
7 |
#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
8 |
# |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
9 |
#See COPYING file for copyrights details. |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
10 |
# |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
11 |
#This library is free software; you can redistribute it and/or |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
12 |
#modify it under the terms of the GNU General Public |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
13 |
#License as published by the Free Software Foundation; either |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
14 |
#version 2.1 of the License, or (at your option) any later version. |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
15 |
# |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
16 |
#This library is distributed in the hope that it will be useful, |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
17 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
18 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
19 |
#General Public License for more details. |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
20 |
# |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
21 |
#You should have received a copy of the GNU General Public |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
22 |
#License along with this library; if not, write to the Free Software |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
23 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
24 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
25 |
import wx |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
26 |
import wx.grid |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
27 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
28 |
class CustomGrid(wx.grid.Grid): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
29 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
30 |
if wx.VERSION < (2, 6, 0): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
31 |
def Bind(self, event, function, id = None): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
32 |
if id is not None: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
33 |
event(self, id, function) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
34 |
else: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
35 |
event(self, function) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
36 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
37 |
def __init__(self, *args, **kwargs): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
38 |
wx.grid.Grid.__init__(self, *args, **kwargs) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
39 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
40 |
if wx.VERSION >= (2, 6, 0): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
41 |
self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnSelectCell) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
42 |
else: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
43 |
wx.grid.EVT_GRID_SELECT_CELL(self, self.OnSelectCell) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
44 |
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
45 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
46 |
def SetDefaultValue(self, default_value): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
47 |
self.DefaultValue = default_value |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
48 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
49 |
def SetButtons(self, buttons): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
50 |
for name in ["Add", "Delete", "Up", "Down"]: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
51 |
button = buttons.get(name, None) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
52 |
setattr(self, "%sButton" % name, button) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
53 |
if button is not None: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
54 |
button.Bind(wx.EVT_BUTTON, getattr(self, "On%sButton" % name)) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
55 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
56 |
def RefreshButtons(self): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
57 |
rows = self.Table.GetNumberRows() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
58 |
row = self.GetGridCursorRow() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
59 |
if self.DeleteButton is not None: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
60 |
self.DeleteButton.Enable(rows > 0) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
61 |
if self.UpButton is not None: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
62 |
self.UpButton.Enable(row > 0) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
63 |
if self.DownButton is not None: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
64 |
self.DownButton.Enable(0 <= row < rows - 1) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
65 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
66 |
def CloseEditControl(self): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
67 |
self.SetGridCursor(self.GetGridCursorRow(), self.GetGridCursorCol()) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
68 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
69 |
def AddRow(self): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
70 |
self.CloseEditControl() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
71 |
new_row = self.GetGridCursorRow() + 1 |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
72 |
col = max(self.GetGridCursorCol(), 0) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
73 |
if getattr(self, "_AddRow", None) is not None: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
74 |
new_row = self._AddRow(new_row) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
75 |
else: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
76 |
self.Table.InsertRow(new_row, self.DefaultValue.copy()) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
77 |
self.Table.ResetView(self) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
78 |
self.SetGridCursor(new_row, col) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
79 |
self.MakeCellVisible(new_row, col) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
80 |
self.RefreshButtons() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
81 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
82 |
def DeleteRow(self): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
83 |
self.CloseEditControl() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
84 |
row = self.GetGridCursorRow() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
85 |
if row >= 0: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
86 |
col = self.GetGridCursorCol() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
87 |
if getattr(self, "_DeleteRow", None) is not None: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
88 |
self._DeleteRow(row) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
89 |
else: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
90 |
self.Table.RemoveRow(row) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
91 |
self.Table.ResetView(self) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
92 |
new_row = min(row, self.Table.GetNumberRows() - 1) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
93 |
self.SetGridCursor(new_row, col) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
94 |
self.MakeCellVisible(new_row, col) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
95 |
self.RefreshButtons() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
96 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
97 |
def MoveRow(self, row, move): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
98 |
self.CloseEditControl() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
99 |
col = self.GetGridCursorCol() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
100 |
if getattr(self, "_MoveRow", None) is not None: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
101 |
new_row = self._MoveRow(row, move) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
102 |
else: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
103 |
new_row = self.Table.MoveRow(row, move) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
104 |
if new_row != row: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
105 |
self.Table.ResetView(self) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
106 |
if new_row != row: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
107 |
self.SetGridCursor(new_row, col) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
108 |
self.MakeCellVisible(new_row, col) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
109 |
self.RefreshButtons() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
110 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
111 |
def OnAddButton(self, event): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
112 |
self.AddRow() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
113 |
self.SetFocus() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
114 |
event.Skip() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
115 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
116 |
def OnDeleteButton(self, event): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
117 |
self.DeleteRow() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
118 |
self.SetFocus() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
119 |
event.Skip() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
120 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
121 |
def OnUpButton(self, event): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
122 |
self.MoveRow(self.GetGridCursorRow(), -1) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
123 |
self.SetFocus() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
124 |
event.Skip() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
125 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
126 |
def OnDownButton(self, event): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
127 |
self.MoveRow(self.GetGridCursorRow(), 1) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
128 |
self.SetFocus() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
129 |
event.Skip() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
130 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
131 |
def OnSelectCell(self, event): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
132 |
wx.CallAfter(self.RefreshButtons) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
133 |
event.Skip() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
134 |
|
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
135 |
def OnKeyDown(self, event): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
136 |
key_handled = False |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
137 |
keycode = event.GetKeyCode() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
138 |
if keycode == wx.WXK_TAB: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
139 |
row = self.GetGridCursorRow() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
140 |
col = self.GetGridCursorCol() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
141 |
if event.ShiftDown(): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
142 |
if row < 0 or col == 0: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
143 |
self.Navigate(wx.NavigationKeyEvent.IsBackward) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
144 |
key_handled = True |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
145 |
elif row < 0 or col == self.Table.GetNumberCols() - 1: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
146 |
self.Navigate(wx.NavigationKeyEvent.IsForward) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
147 |
key_handled = True |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
148 |
elif keycode in (wx.WXK_ADD, wx.WXK_NUMPAD_ADD): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
149 |
self.AddRow() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
150 |
key_handled = True |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
151 |
elif keycode in (wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
152 |
self.DeleteRow() |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
153 |
key_handled = True |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
154 |
elif keycode == wx.WXK_UP and event.ShiftDown(): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
155 |
self.MoveRow(self.GetGridCursorRow(), -1) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
156 |
key_handled = True |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
157 |
elif keycode == wx.WXK_DOWN and event.ShiftDown(): |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
158 |
self.MoveRow(self.GetGridCursorRow(), 1) |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
159 |
key_handled = True |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
160 |
if not key_handled: |
9dbb79722fbc
Adding support for giving keyboard focus to the first control of every dialogs
laurent
parents:
diff
changeset
|
161 |
event.Skip() |