Re: VerifyListener in a TextCellEditor... bug? [message #107865] |
Fri, 07 October 2005 02:38 |
Eclipse User |
|
|
|
pls try this.
To handle the case that more than one character is inserted (e.g. copy and
paste, click a text editor) and less than one character is inserted (e.g.
delete text, e.text="")
public void verifyText(VerifyEvent e) {
boolean result=true;
if (e.text.length()==1){
result = "0123456789.".indexOf(e.text) >= 0 ;
}
e.doit = result;
}
"José Ángel García" <desarrollo@xxxxxxxxxxxxxxxxxxx> wrote in message
news:d6cgmf$ck6$1@xxxxxxxxxxxxxxxxxxx
> Hi, I'm using a tableviewer with CellModifiers, so I add the
> celleditors and one of them has a verifyListener:
>
> CellEditor editors [] = new CellEditor[col.length];
> TextCellEditor textDecimalEditor = new TextCellEditor(table);
>
> ((Text)textDecimalEditor.getControl()).addVerifyListener(
> new VerifyListener(){
> public void verifyText(VerifyEvent e) {
> e.doit = "0123456789,".indexOf(e.text) >= 0;
> }
> }
>
> editors[0] = new TextCellEditor(table);
> editors[1] = comboEditorFamilias;
> editors[2] = textDecimalEditor;
> editors[3] = textDecimalEditor;
>
> tableViewer.setColumnProperties(col);
> tableViewer.setCellEditors(editors);
> tableViewer.setCellModifier(new VelMedCellModifier(tableViewer, col, df,
> modificados ));
>
> tableViewer.setInput(datosTuplas);
>
>
> The problem is that when i click on a cell and it changes to edit mode,
> it don't shows the value to edit. It deletes the content of the cell
> (only in the edit mode, if i press esc it returns de value, i have
> checket the getValue() method and returns the value correctly)... the
> correct behaivour is to select the content of the cell to edit..
>
> Another strange behavour is that: if i change the content of a cell and
> the click in another to edit that last.. it pastes the modified value of
> the first cell....
>
> This don't happen without the verifyListener.
>
>
> Is it a bug? any other way of controlling the user input?
>
> Thanks in advance...
>
> P.S.: Excuse my english...
|
|
|
Powered by
FUDForum. Page generated in 0.47503 seconds