CTRL+A to select all records in a grid

Hallo guys,
I’m using the latest version of smartGWTEE and I’m trying to implement the following feature: if we type CTRL+A all records in the grid get selected.

My implementation:

KeyIdentifier selectAllKey = new KeyIdentifier();
selectAllKey.setCtrlKey(true);
selectAllKey.setKeyName("A");
	 
Page.registerKey(selectAllKey, new KeyCallback() {
	public void execute(String keyName) {
		myGrid.selectAllRecords();
	}
});

Which works,I mean the records in the grid DO get selected, BUT the problem is: the whole page gets selected as well (marked in blue like when we select something on a text on a webpage)
Which is weird because I didn’t set “canSelectText” anywhere in my application and the standard behaviour for smartgwt widget is false, and actually if I try to select some text on any widget I can’t, it just appears selected when I press CTRL+A
So I’m asking myself, it possible at all to avoid this, or is it a native browser hot key (like CTRL+N for opening another window) which is impossible to disable?
Thanks in advance for your help

Laura

We have limited control over text selection (in older browsers, almost none). The best way to handle this is to add an event handler to catch Ctrl-A and call selectAllRecords on the grid.

Isomorphic thanks for your reply. The applicatoin has to work on tIE 7+, so we don’t need old browsers compatibility.

I tried already the solution u suggested, and it didn’t work.

grid.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
if (event.getKeyName().equals(“A”) && event.isCtrlKeyDown()) {
hourSequenceGrid.selectAllRecords();
overviewGrid.selectAllRecords();
}
}
});

I never get into the IF, because event.getKeyName is always Ctrl and not A, even when I press Ctrl A
Tried also EventHandler.getKeyName(): same thing.
Tried a keyDownHandler as well, no result
It looks like in this events handlers only a single key press is intercepted.

Am I doing something wrong, or is the API like this?
Thanks

Laura

Hi
Any update in this issue ???

I use this with FF 13.0.1 , and i have same issue , every thing in browser will be selected when i press Ctrl - A

how can i prevent that ? should i use other way ?

Solving issue

we can solve this by add key press handler to listgrid

myListGrid.addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
if (event.getKeyName().equals(“A”) && event.isCtrlKeyDown() ) {
…
event.cancel();
}
}
});