DefaultSelectionEventManager. It tries to toggle the cell selection
when you push the space key. CellList extends AbstractHasData which in
turn uses the DefaultSelectionEventManager.
The behaviour seems even stranger if you don't have a SelectionModel
set for your CellList. If you set one (you can use 'new
SingleSelectionModel<T>' on your CellList object, where T is your
model class) and you will see that the space key event toggles the row
selection..
I'm not sure if there is a bug report for this yet? We will need to
wait for it to be fixed / explained but until then I developed this
little hack :) Paste it anywhere.. it's static. Tested on Chrome and
FF4 but probably won't work on some older browsers.
Event.addNativePreviewHandler(new NativePreviewHandler() {
@Override
public void onPreviewNativeEvent(NativePreviewEvent event) {
NativeEvent nativeEvent = event.getNativeEvent();
final int keyCode = nativeEvent.getKeyCode();
final boolean isNotAnInputElement = !InputElement
.is(nativeEvent.getEventTarget());
final boolean isNotTheSpaceKey = keyCode != 32;
if (isNotAnInputElement || isNotTheSpaceKey) {
return;
}
String type = nativeEvent.getType();
event.cancel();
if (("keyup".equals(type))) {
InputElement element = nativeEvent.getEventTarget().cast();
final int start = element.getPropertyInt("selectionStart");
final int end = element.getPropertyInt("selectionEnd");
if (start == end) {
String before = element.getValue();
String after = before.substring(0, start) + " "
+ before.substring(start);
element.setValue(after);
element.setPropertyInt("selectionStart", start + 1);
element.setPropertyInt("selectionEnd", start + 1);
}
}
}
});
On Jan 24, 11:06 am, Bernd <xbern...@hotmail.com> wrote:
> Please try the following: Put an EditTextCell into a CompositeCell and
> add the CompositeCell to a CellTable Column. Now enter the
> EditTextCells edit mode to change the text and try to add a space-char
> by pressing your space key. Unfortunately, this doesn't work for me
> (Firefox 3.5).
> I checked the events which are forwarded by the Browser to the
> CompositeCell. Interestingly, there is no "downkey" event delivered
> for the space key. Maybe this has something to do with it?
>
> Here is the sample code i used to generate the CellTable Column:
>
> final EditTextCell editTexCell = new EditTextCell();
>
> HasCell<String, String> hasC = new HasCell<String,
> String>() {
>
> @Override
> public Cell<String> getCell() {
> return editTexCell;
> }
>
> @Override
> public FieldUpdater<String, String> getFieldUpdater() {
> return null;
> }
>
> @Override
> public String getValue(String object) {
> return object;
> }
>
> };
>
> List<HasCell<String, ?>> listHC = new ArrayList<HasCell<String, ?>>();
>
> listHC.add(hasC);
> CompositeCell compCell = new CompositeCell<String>(listHC);
>
> Column<RowOfData, String> compCellColumn = new Column<RowOfData,
> String>(compCell) {
> @Override
> public String getValue(RowOfData object) {
> return "test123";
> }
> };
>
> Is there a way to fix this problem?
> A positive answer would help me a lot :)
> Thanks!
> Bernd
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment