EmbeddedFormattedTextEdit bug?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

EmbeddedFormattedTextEdit bug?

Louis Sumberg-2
I'm using SSW's EditableListView, which is great, btw, but have run into a
problem with the date widget.  The problem can actually be seen with the
demo shell, i.e., run EditableListViewDemo and you'll notice that the date
on the first line is 1/1/1970.  However, if you tab through the cells, the
date changes to 11/19/1970.  My Locale is English/USA so this doesn't
generate an error, but obviously it's doing a naughty thing.  Try changing
the date to say, 3/2/04.  When you tab out of the cell, it looks ok, but tab
or click back into it and now it's 32/20/04 and it does generate an error.
I tried debugging, but didn't get too far, though it looks like it's not a
problem in the DateToText typeconverter.

-- Louis


Reply | Threaded
Open this post in threaded view
|

Re: EmbeddedFormattedTextEdit bug?

Yar Hwee Boon-3
On Sun, 15 Aug 2004 14:35:56 -0700, Louis Sumberg  
<[hidden email]> wrote:

> date
> on the first line is 1/1/1970.  However, if you tab through the cells,  
> the
> date changes to 11/19/1970.

Try look at the first line of EmbeddedFormattedTextEdit>>applyFormat. That  
looks like it assumes a fixed width date string (ie. '01/01/1970' instead  
of '1/1/1970').

        self text reject: [ :char | self isSeparator: char].

--
Regards
Hwee Boon
MotionObj


Reply | Threaded
Open this post in threaded view
|

Re: EmbeddedFormattedTextEdit bug?

John Aspinall-5
In reply to this post by Louis Sumberg-2
Louis,

> I'm using SSW's EditableListView, which is great, btw, but have run into a
> problem with the date widget.  The problem can actually be seen with the
> demo shell, i.e., run EditableListViewDemo and you'll notice that the date
> on the first line is 1/1/1970.  However, if you tab through the cells, the
> date changes to 11/19/1970.  My Locale is English/USA so this doesn't
> generate an error, but obviously it's doing a naughty thing.

Ah... excuse my euro-centricism.

Ultimately I think the control needs some locale-awareness (currently
EmbeddedFormattedTextEdit class>>newForDate has the format hard-coded), but the
patch below should solve your immediate problem.

Best regards,

John Aspinall
Solutions Software


!FormattedTextEdit methodsFor!

applyFormat

 | inStream formatStream outStream text |

 inStream := ReadStream on: self text.
 formatStream := ReadStream on: self format.
 outStream := WriteStream on: (String new: self format size).

 [formatStream atEnd] whileFalse:
  [| char formatChar |
  formatChar := formatStream next.
  (self isSeparator: formatChar)
  ifTrue:
   [char := formatChar.
   inStream skipTo: formatChar]
  ifFalse:
   [(inStream atEnd or: [self isSeparator: inStream peek])
    ifTrue: [char := self placeholderChar]
    ifFalse: [char := inStream next]].
  outStream nextPut: char].

 text := outStream contents.
 self text: text.
 ^text


! !
!FormattedTextEdit categoriesFor: #applyFormat!helpers!private! !


Reply | Threaded
Open this post in threaded view
|

Re: EmbeddedFormattedTextEdit bug?

Louis Sumberg-2
John,

Thanks for the speedy patch - it works great.  Thanks also to Hwee Boon for
spotting it as a fixed width problem in #applyFormat.  Also, as far as
locale goes, it seems to pick that up fine.

John, I should also mention there's an oddity in the demo, i.e., John
Smith's gender can't be changed.  John Smith might argue this is by
(Nature's) design, but I'm in San Francisco, so that argument doesn't go so
far ;)  Thankfully, I have not seen this behavior in my application.

-- Louis


Reply | Threaded
Open this post in threaded view
|

Re: EmbeddedFormattedTextEdit bug?

John Aspinall-5
Louis,

> Thanks for the speedy patch - it works great.  Thanks also to Hwee Boon for
> spotting it as a fixed width problem in #applyFormat.  Also, as far as
> locale goes, it seems to pick that up fine.

Excellent. For the record, the remaining issue is for locales whose date format
doesn't fit '__/__/____' e.g. according to Windows, the French (Canada) date
format is yyyy-mm-dd, so the editor format should be '____-__-__', with the
separator character set to $-.

> John, I should also mention there's an oddity in the demo, i.e., John
> Smith's gender can't be changed.  John Smith might argue this is by
> (Nature's) design, but I'm in San Francisco, so that argument doesn't go so
> far ;)  Thankfully, I have not seen this behavior in my application.

This *is* actually by design(!), dependent on the individual's marital status.
It's intended to demonstrate the ability to enable/disable an editor for an
individual line. As it says in onViewOpened:

"And (for no good reason) only enable it when the person is not married"
self genderColumn isEditableBlock: [ :person | person isMarried not]

Best regards,

John Aspinall
Solutions Software