| 246 | # |
| 247 | |
| 248 | class TextEditFinishEventFilter(qt.QObject): |
| 249 | |
| 250 | def __init__(self, *args, **kwargs): |
| 251 | qt.QObject.__init__(self, *args, **kwargs) |
| 252 | self.textEditFinishedCallback = None |
| 253 | |
| 254 | def eventFilter(self, object, event): |
| 255 | if self.textEditFinishedCallback is None: |
| 256 | return |
| 257 | if (event.type() == qt.QEvent.KeyPress and event.key() in (qt.Qt.Key_Return, qt.Qt.Key_Enter) |
| 258 | and (event.modifiers() & qt.Qt.ControlModifier)): |
| 259 | self.textEditFinishedCallback() |
| 260 | return True # stop further handling |
| 261 | return False |
| 262 | |
| 263 | class SampleDataWidget(ScriptedLoadableModuleWidget): |
| 264 | """Uses ScriptedLoadableModuleWidget base class, available at: |