Last change
on this file since 639 was 623, checked in by Nicholas Riley, 15 years ago |
Date autocomplete: replace a bunch of hacks with easier-to-read, less buggy code now we control the field editor.
Still need to move autocompletion into PSTimeDateEditor and fix one small autocomplete bug.
|
File size:
1.2 KB
|
Line | |
---|
1 | //
|
---|
2 | // PSDateFieldEditor.m
|
---|
3 | // Pester
|
---|
4 | //
|
---|
5 | // Created by Nicholas Riley on 3/1/10.
|
---|
6 | // Copyright 2010 Nicholas Riley. All rights reserved.
|
---|
7 | //
|
---|
8 |
|
---|
9 | #import "PSDateFieldEditor.h"
|
---|
10 |
|
---|
11 |
|
---|
12 | @implementation PSDateFieldEditor
|
---|
13 |
|
---|
14 | - (void)insertText:(id)insertString;
|
---|
15 | {
|
---|
16 | [super insertText: insertString];
|
---|
17 | [self complete: nil];
|
---|
18 | // XXX if we *do* successfully complete, need to delete remainder
|
---|
19 | // XXX example: in "today", select "t" then retype it
|
---|
20 | }
|
---|
21 |
|
---|
22 | - (void)moveDown:(id)sender;
|
---|
23 | {
|
---|
24 | [self deleteToEndOfLine: sender];
|
---|
25 | [self complete: sender];
|
---|
26 | }
|
---|
27 |
|
---|
28 | @end
|
---|
29 |
|
---|
30 | @implementation PSDateFieldEditor (NSCompletion)
|
---|
31 |
|
---|
32 | - (NSRange)rangeForUserCompletion;
|
---|
33 | {
|
---|
34 | NSRange range = [super rangeForUserCompletion];
|
---|
35 | range.length += range.location;
|
---|
36 | range.location = 0;
|
---|
37 |
|
---|
38 | return range;
|
---|
39 | }
|
---|
40 |
|
---|
41 | - (void)insertCompletion:(NSString *)word forPartialWordRange:(NSRange)charRange movement:(int)movement isFinal:(BOOL)flag;
|
---|
42 | {
|
---|
43 | // space bar (or right arrow, which is less ideal)
|
---|
44 | if (movement == NSRightTextMovement)
|
---|
45 | flag = NO;
|
---|
46 |
|
---|
47 | [super insertCompletion:word forPartialWordRange:charRange movement:movement isFinal:flag];
|
---|
48 |
|
---|
49 | if (movement == NSTabTextMovement)
|
---|
50 | [self insertTab: nil];
|
---|
51 | }
|
---|
52 |
|
---|
53 | @end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.