09-28-2011, 02:11 PM,
|
|||||
|
|||||
RE: Setting a value to DateField by keyboard
That's about right but I believe your indices are incorrect.
Though the documentation for parse-spec is not entirely detailed on this point, the indices to return are selection indices, not character indices. The difference being that selection indices are to the left of the character indices in the string. This means that, for a fixed format of YYYYMMDD, you would return (0,4)(4,6)(6,8) instead of (0,3)(4,5)(6,7). Plus you should still set date-format-spec -- though this is not clear at all from the documentation. (Also you should set it first so that it doesn't override your parse-spec and format-spec.) Probably the documentation could be improved here, and I will make a note of that. Also I think some of your returned indices are incorrect even with the assumption of character indices. You can tell there's an issue by pressing up and down in the DateField; this should get you single year/month/day moves, but the selection is short by an index, so looks weird, and it can miss the desired change depending on where the caret index is. I haven't extensively tested this, but I think this reflects what you were aiming for: Code: {curl 7.0, 8.0 applet} Note that I changed the formatting somewhat and removed the extraneous StringBufs. As a note to others who might use this code, like the original code sample, it doesn't properly handle all possible DateField.separators, or unbalanced separators. For production, I would want to look at improving that aspect of parsing. |
|||||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Setting a value to DateField by keyboard - by alchimiste - 09-27-2011, 02:15 PM
RE: Setting a value to DateField by keyboard - by c-s - 09-27-2011, 05:45 PM
RE: Setting a value to DateField by keyboard - by alchimiste - 09-27-2011, 07:49 PM
RE: Setting a value to DateField by keyboard - by c-s - 09-28-2011, 02:11 PM
RE: Setting a value to DateField by keyboard - by alchimiste - 09-28-2011, 06:06 PM
|
Possibly Related Threads... | |||||
Thread | Author | Replies | Views | Last Post | |
DateField の ValueFinished の抑制 | umemura | 1 | 2,597 |
01-24-2013, 08:10 PM Last Post: umemura |
Users browsing this thread:
1 Guest(s)
1 Guest(s)