Mercurial > projects > mde
comparison mde/content/AStringContent.d @ 162:2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Fri, 22 May 2009 19:59:22 +0200 |
parents | 9f035cd139c6 |
children | 24d77c52243f |
comparison
equal
deleted
inserted
replaced
161:e3fe6acc16fb | 162:2476790223b8 |
---|---|
47 override char[] toString (uint i) { | 47 override char[] toString (uint i) { |
48 return i == 0 ? sv | 48 return i == 0 ? sv |
49 : i == 1 ? name_ | 49 : i == 1 ? name_ |
50 : i == 2 ? desc_ | 50 : i == 2 ? desc_ |
51 : null; | 51 : null; |
52 } | |
53 | |
54 /** Set the content via conversion to/from string. */ | |
55 override bool setContent (IContent c) { | |
56 AStringContent asc = cast (AStringContent) c; | |
57 if (asc !is null) { | |
58 try { | |
59 sv = asc.toString (0); | |
60 endEdit; | |
61 } catch (Exception) { // invalid conversion; just reject c | |
62 return false; | |
63 } | |
64 return true; | |
65 } | |
66 return false; | |
52 } | 67 } |
53 | 68 |
54 /** Acts on a keystroke and returns the new value. | 69 /** Acts on a keystroke and returns the new value. |
55 * | 70 * |
56 * Supports one-line editing: left/right, home/end, backspace/delete. */ | 71 * Supports one-line editing: left/right, home/end, backspace/delete. */ |
221 v = *valp; | 236 v = *valp; |
222 sv = Int.toString (v); | 237 sv = Int.toString (v); |
223 super (symbol); | 238 super (symbol); |
224 } | 239 } |
225 | 240 |
241 // NOTE: the only point of this method is to avoid int->string->int conversions, | |
242 // and perhaps specialise (double->int rounding?) | |
243 override bool setContent (IContent c) { | |
244 IntContent ic = cast (IntContent) c; | |
245 if (ic !is null) { | |
246 this = ic(); | |
247 return true; | |
248 } | |
249 return super.setContent (c); | |
250 } | |
251 | |
226 void assignNoCng (int val) { | 252 void assignNoCng (int val) { |
227 v = val; | 253 v = val; |
228 sv = Int.toString (v); | 254 sv = Int.toString (v); |
229 if (pos > sv.length) pos = sv.length; | 255 if (pos > sv.length) pos = sv.length; |
230 endEvent; | 256 endEvent; |