PDA

View Full Version : HtmlEditor - KeyPress event



SergeMat
18 Aug 2010, 4:53 AM
Hello,
In my project, I need to create a custom HtmlEditor because we need to display (when entering values in textarea)

the number of char remaining before reaching the maxlength of chars permited in the HtmlEditor.

Is there a way to do it ?

bellow, my code for registering to the event:



htmlEditor.addListener(Events.OnKeyPress, new Listener<FieldEvent>() {

public void handleEvent(FieldEvent be) {
TextArea t = (TextArea) be.getField();
String value = t.getValue();
int length = value != null ? value.length() : 0;
charsCount.setText(length + (length == 1 ? " Char" : " Chars"));
task.delay(1000);
}
}); I have tried to debug it but the event is never fired !!!
charsCount is a Status component

Any idea ?

Thanks

sven
18 Aug 2010, 4:57 AM
This is a bit more complicated in HtmlEditor. In GXT 2.2 you can extend HtmlEditor and override onEditorKeyDown. This method is not part of the RC release, but will be part of the final.

SergeMat
18 Aug 2010, 5:30 AM
Thank you for your reply Sven.

Does it mean that there is no way to reach a solution for my problem with version 2.1.1-gxt?

What is the RC release ?

SergeMat
18 Aug 2010, 6:21 AM
Sorry for the RC question :)
Release Candidate.