* Ctrl+C is not a global key binding anymore, so default Ctrl+C behaviour (copy) should work in edit fields now in the MainWindow.

* Enter now produces the expected behaviour when the program has just started

git-svn-id: https://ipscan.svn.sourceforge.net/svnroot/ipscan/trunk@148 375186e5-ef17-0410-b0b6-91563547dcda
This commit is contained in:
angryziber 2007-07-11 22:30:57 +00:00
parent bc230c962c
commit 74412a52d6
4 changed files with 22 additions and 7 deletions

View File

@ -21,8 +21,8 @@ menu.commands.show=Show
menu.commands.open=Open
menu.commands.open.edit=Edit openers...
menu.favorites=Fa&vorites
menu.favorites.add=Add current...
menu.favorites.edit=Manage favorites...
menu.favorites.add=Ad&d current...
menu.favorites.edit=&Manage favorites...
menu.tools=&Tools
menu.tools.options=&Options...
menu.tools.fetchers=Select &fetchers...

View File

@ -110,9 +110,9 @@ public class MainMenu {
initMenuItem(menu, "menu.commands.details", null, null, initListener(CommandsActions.Details.class));
initMenuItem(menu, null, null, null, null);
initMenuItem(menu, "menu.commands.rescan", "Ctrl+R", new Integer(SWT.MOD1 | 'R'), initListener(CommandsActions.Rescan.class));
initMenuItem(menu, "menu.commands.delete", "Del", null, initListener(CommandsActions.Delete.class));
initMenuItem(menu, "menu.commands.delete", "Del", /* this is not a global key binding */ null, initListener(CommandsActions.Delete.class));
initMenuItem(menu, null, null, null, null);
initMenuItem(menu, "menu.commands.copy", "Ctrl+C", new Integer(SWT.MOD1 | 'C'), initListener(CommandsActions.CopyIP.class));
initMenuItem(menu, "menu.commands.copy", "Ctrl+C", /* this is not a global key binding */ null, initListener(CommandsActions.CopyIP.class));
initMenuItem(menu, "menu.commands.copyDetails", null, null, initListener(CommandsActions.CopyIPDetails.class));
initMenuItem(menu, null, null, null, null);
createOpenersMenu(menu);

View File

@ -65,16 +65,19 @@ public class ResultTable extends Table implements FetcherRegistryUpdateListener
Listener detailsListener = new Listener() {
CommandsActions.Details detailsListener = new CommandsActions.Details(ResultTable.this);
public void handleEvent(Event e) {
if (e.type == SWT.MouseDoubleClick || e.detail == SWT.TRAVERSE_RETURN) {
detailsListener.handleEvent(e);
// activate only if something is selected
if (getSelectionIndex() >= 0 && (e.type == SWT.MouseDoubleClick || e.detail == SWT.TRAVERSE_RETURN)) {
e.doit = false;
detailsListener.handleEvent(e);
}
}
};
addListener(SWT.Traverse, detailsListener);
addListener(SWT.MouseDoubleClick, detailsListener);
addListener(SWT.KeyDown, new CommandsActions.Delete(this));
addListener(SWT.KeyDown, new CommandsActions.CopyIP(this));
// this one populates table dynamically, taking data from ScanningResultList
addListener(SWT.SetData, new SetDataListener());
}

View File

@ -96,6 +96,10 @@ public class CommandsActions {
}
}
/**
* Copies currently selected IP to the clipboard.
* Used as both menu item listener and keydown listener.
*/
public static class CopyIP implements Listener {
private ResultTable resultTable;
@ -104,7 +108,15 @@ public class CommandsActions {
}
public void handleEvent(Event event) {
checkSelection(resultTable);
if (event.type == SWT.KeyDown) {
// if this is not Ctrl+C or nothing is selected, then simply do nothing
if ((event.keyCode != 'c' && event.stateMask != SWT.MOD1) || resultTable.getSelectionIndex() < 0)
return;
}
else {
// if selected from the menu, check selection
checkSelection(resultTable);
}
Clipboard clipboard = new Clipboard(event.display);
clipboard.setContents(new Object[] {resultTable.getItem(resultTable.getSelectionIndex()).getText()}, new Transfer[] {TextTransfer.getInstance()});
clipboard.dispose();