Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Enable key 'J' and 'K' to navigate with 'Enter' to open editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Oct 17, 2011
1 parent cecd7a9 commit afbb9cd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
Expand Up @@ -186,7 +186,6 @@ public void onValueChange(ValueChangeEvent<String> event)
@Override
public void onBlur(BlurEvent event)
{
Log.debug("text area focus lost");
isFocused = false;
}
});
Expand Down
Expand Up @@ -495,6 +495,13 @@ public void onCopySource(CopySourceEvent event)

}));

/** @formatter:off
* Navigation mode shortcuts key
* ALT+UP arrow or J - Previous entry
* ALT+DOWN arrow or K - Next entry
* ALT+G copy from source
* Enter - Open editor
*/
Event.addNativePreviewHandler(new NativePreviewHandler()
{
@Override
Expand All @@ -511,27 +518,36 @@ public void onPreviewNativeEvent(NativePreviewEvent event)
boolean altKey = nativeEvent.getAltKey();
boolean ctrlKey = nativeEvent.getCtrlKey();

if (nativeEventType.equals("keydown") && altKey)
if (nativeEventType.equals("keydown"))
{
if (keyCode == KeyCodes.KEY_UP || keyCode == TableConstants.KEY_J)
if ((altKey && keyCode == KeyCodes.KEY_UP) || keyCode == TableConstants.KEY_J)
{
Log.info("Go to previous entry");
tableModelHandler.gotoPrevRow(false);
event.cancel();
}
else if (keyCode == KeyCodes.KEY_DOWN || keyCode == TableConstants.KEY_K)
else if ((altKey && keyCode == KeyCodes.KEY_DOWN) || keyCode == TableConstants.KEY_K)
{
Log.info("Go to next entry");
tableModelHandler.gotoNextRow(false);
event.cancel();
}
else if (keyCode == TableConstants.KEY_G)
else if (altKey && keyCode == TableConstants.KEY_G)
{
if (selectedTransUnit != null)
{
Log.info("Copy from source");
tableModelHandler.gotoRow(curRowIndex);
display.getTargetCellEditor().cloneAction();
event.cancel();
}
}
else if(keyCode == KeyCodes.KEY_ENTER){
if (selectedTransUnit != null)
{
Log.info("open editor");
tableModelHandler.gotoRow(curRowIndex);
event.cancel();
}
}
}
Expand Down
Expand Up @@ -56,8 +56,7 @@ private ArrayList<DocumentInfo> generateTransUnitSampleData()
for (int n = 10; n < 129; n++)
{
// two digit numbers, to make sorting happier
// names.add(new DocumentInfo(new DocumentId(n), "multi" + n, "",
// newStats(n)));
names.add(new DocumentInfo(new DocumentId(n), "multi" + n, "", newStats(n)));
}
return names;
}
Expand Down

0 comments on commit afbb9cd

Please sign in to comment.