smartGWT 프로젝트의 타일 그리드에 파일 아이콘을로드하고 있습니다. Enter 키를 누르면 표시 할 파일을 열려고합니다.smartGWT TileGrid :: onKeyPress - Enter 키를 재정의하는 방법, 다른 키의 기본 처리 유지
onKeyPress 처리기를 재정의하면 작동하지만 왼쪽/오른쪽/위/아래 화살표 키를 사용하여 타일 그리드 탐색 동작이 손실됩니다.
내 질문은 .. Enter 키를 무시하면서 기본 처리 동작을 유지하는 방법입니다.
tileGrid.addKeyPressHandler (new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
if (EventHandler.getKey().equals("Enter")) {
//do something special here
}
else {
**//TODO: do the default processing..**.
}
}
});
는 편집 :
는@Ras, 여기에 문제를 시뮬레이션 코드입니다.
package com.rv.gwtsample.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.widgets.events.KeyPressEvent;
import com.smartgwt.client.widgets.events.KeyPressHandler;
import com.smartgwt.client.widgets.tile.TileGrid;
import com.smartgwt.client.widgets.tile.TileRecord;
/**
* @author rvnath
*
*/
public class MyTileGrid implements EntryPoint {
/* (non-Javadoc)
* @see com.google.gwt.core.client.EntryPoint#onModuleLoad()
*/
@Override
public void onModuleLoad() {
// TODO Auto-generated method stub
TileGrid grid = new TileGrid();
grid.setLeft(50);
grid.setTop(50);
grid.setWidth("300");
grid.setHeight("200");
DetailViewerField field = new DetailViewerField("Name");
grid.setFields(field);
grid.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
if (event.getKeyName().equals("Enter"))
GWT.log("Enter pressed");
}
});
Record[] rec = new TileRecord[32];
for (int i=0; i<32; ++i) {
rec[i] = new TileRecord();
}
grid.setData(rec);
grid.draw();
}
}
onKeyPress 핸들러를 비활성화하면 화살표 키가 타일 격자 요소 사이를 탐색 할 수 있습니다. 활성화하면 선택 항목 변경 대신 전체 타일 격자 패널이 스크롤됩니다.
안녕하세요 @RAS, 코드 스 니펫을 추가했습니다. 이 문제를 해결할 수 있다면 알려주십시오. 미리 감사드립니다 ... –
@MupparthyRavindranath, 'else'문을 제거 해봤습니까? – RAS
안녕하세요 @ 라스, 코드에 'else'문이 없습니다. "Enter"키를 처리하기위한 If. –