开发者

How make cursor doesn't go in new line when i press Enter in TextArea (in GWT)?

I tried method te开发者_Python百科xtArea.setCursorPos(0) but it didn't work. May be it is posiible to resolve by Java Script but i don't know((


In JavaScript you can use return false; or event.returnValue = false; (IE), event.preventDefault(); (FF, Chromium, Opera) in event handler.

With GWT you just use the NativeEvent's preventDefault() method

area.addKeyPressHandler(new KeyPressHandler() {
  @Override
  public void onKeyPress(KeyPressEvent event) {
    if (event.getCharCode() == 13) {
      event.preventDefault();
    }
  }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜