Changeset 150
- Timestamp:
- 03/08/08 01:01:27 (10 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
packages/defconAppKit/trunk/Lib/defconAppKit/views/glyphNameComboBox.py
r147 r150 1 1 from AppKit import * 2 2 import vanilla 3 3 4 4 5 class GlyphNameComboBox(vanilla.EditText): … … 8 9 self._font = font 9 10 self._finalCallback = callback 11 self._currentText = "" 10 12 11 13 def _breakCycles(self): … … 15 17 16 18 def _textInputCallback(self, sender): 17 input, match = self._searchForMatch(self.get()) 19 input = sender.get() 20 deleting = False 21 if len(input) <= len(self._currentText): 22 if self._currentText.startswith(input): 23 deleting = True 24 self._currentText = input 25 input, match = self._searchForMatch(input, deleting=deleting) 18 26 if match is None: 19 27 return … … 25 33 window = textField.window() 26 34 fieldEditor = window.fieldEditor_forObject_(True, textField) 27 fieldEditor.setSelectedRange_((selectionStart, selectionLength)) 35 if not deleting: 36 fieldEditor.setSelectedRange_((selectionStart, selectionLength)) 28 37 if self._finalCallback is not None: 29 38 self._finalCallback(self) 30 39 31 def _searchForMatch(self, text ):40 def _searchForMatch(self, text, deleting=False): 32 41 # no text 33 42 if not text: … … 47 56 if match is None: 48 57 glyphNames = list(sorted(glyphNames)) 49 for glyphName in glyphNames: 50 if glyphName.startswith(text): 51 match = glyphName 52 break 58 if not deleting: 59 for glyphName in glyphNames: 60 if glyphName.startswith(text): 61 match = glyphName 62 break 63 else: 64 for glyphName in glyphNames: 65 if text.startswith(glyphName): 66 match = glyphName 67 elif match is not None: 68 break 53 69 return text, match 54 70 55
