09-27-2011, 02:15 PM,
|
|||||
|
|||||
Setting a value to DateField by keyboard
Hi,
I used DateField as below, the date format is YYYYMMDD Users want input the value by keyboard as displaying format, this is impossibe because DateField allows text with only DD/MM/YYYY format How can other format that we wish be allowed? Code: {DateField |
|||||
09-27-2011, 05:45 PM,
|
|||||
|
|||||
RE: Setting a value to DateField by keyboard
I suspect that you should actually be looking at date-format-spec.
date-format-spec == DateFieldFormatSpec.iso seems to match your desired parse/format rules. If you have more complicated needs, you can ignore that and set parse-spec in addition to format-spec, but that is certainly more work. |
|||||
09-27-2011, 07:49 PM,
(This post was last modified: 09-27-2011, 07:50 PM by alchimiste.)
|
|||||
|
|||||
RE: Setting a value to DateField by keyboard
Thanks a lot..
I implement what users want with your help. The modified code as below: PHP Code: {DateField |
|||||
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. |
|||||
09-28-2011, 06:06 PM,
|
|||||
|
|||||
RE: Setting a value to DateField by keyboard
Thanks again...
When I read your reply first, I didn't understand what the selection that you said means. I've found that I can change year, month and day by pressing UP or DOWN key in DateFiel, and so I understand what you said. That's great and very interesting. I hope the documentation of Curl IDE would be more detailed. |
|||||
« Next Oldest | Next Newest »
|
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)