diff --git a/source/org/thdl/tib/scanner/DuffScannerPanel.java b/source/org/thdl/tib/scanner/DuffScannerPanel.java index c02e67f..f0184d8 100644 --- a/source/org/thdl/tib/scanner/DuffScannerPanel.java +++ b/source/org/thdl/tib/scanner/DuffScannerPanel.java @@ -156,6 +156,11 @@ public class DuffScannerPanel extends ScannerPanel implements ItemListener keyboard.addItemListener(this); toolBar.add(keyboard); } + + public void setFocusToInput() + { + duffInput.requestFocusInWindow(); + } public void addFocusListener(FocusListener fl) { @@ -235,41 +240,42 @@ public class DuffScannerPanel extends ScannerPanel implements ItemListener public void translate() { - String in; - setDicts(scanner.getDictionarySource()); + String in; + setDicts(scanner.getDictionarySource()); - in = ""; - if (showingTibetan) - in = duffInput.getWylie(new boolean[] { false }); - else + in = ""; + if (showingTibetan) + in = duffInput.getWylie(new boolean[] { false }); + else in = txtInput.getText(); - if (!in.equals("")) - { - doingStatus("Translating..."); - scanner.scanBody(in); - scanner.finishUp(); - model.newSearch(scanner.getWordArray()); - //printAllDefs(); - scanner.clearTokens(); - returnStatusToNorm(); - fullDef.setText(""); - /*ListSelectionModel lsm = (ListSelectionModel)table.getSelectionModel(); - if (!lsm.isSelectionEmpty()) - { - int selectedRow = lsm.getMinSelectionIndex(); - //TableModel tm = table.getModel(); - if (selectedRow0) table.setRowSelectionInterval(0,0); } public void setWylieInput(boolean enabled) diff --git a/source/org/thdl/tib/scanner/ScannerPanel.java b/source/org/thdl/tib/scanner/ScannerPanel.java index 3b76cb3..ccb4022 100644 --- a/source/org/thdl/tib/scanner/ScannerPanel.java +++ b/source/org/thdl/tib/scanner/ScannerPanel.java @@ -215,5 +215,6 @@ public abstract class ScannerPanel extends Panel implements ActionListener public abstract void translate(); public abstract void clear(); public abstract void setWylieInput(boolean enabled); + public abstract void setFocusToInput(); public void addFocusListener(FocusListener fl) {} } diff --git a/source/org/thdl/tib/scanner/SimpleScannerPanel.java b/source/org/thdl/tib/scanner/SimpleScannerPanel.java index 9448e34..4d6d99e 100644 --- a/source/org/thdl/tib/scanner/SimpleScannerPanel.java +++ b/source/org/thdl/tib/scanner/SimpleScannerPanel.java @@ -116,6 +116,11 @@ public class SimpleScannerPanel extends ScannerPanel implements ItemListener add(cardPanel, BorderLayout.CENTER); } + public void setFocusToInput() + { + txtInput.requestFocusInWindow(); + } + public void itemStateChanged(ItemEvent e) { int n = listDefs.getSelectedIndex(); diff --git a/source/org/thdl/tib/scanner/SwingWindowScannerFilter.java b/source/org/thdl/tib/scanner/SwingWindowScannerFilter.java index edf4996..04b75e5 100644 --- a/source/org/thdl/tib/scanner/SwingWindowScannerFilter.java +++ b/source/org/thdl/tib/scanner/SwingWindowScannerFilter.java @@ -18,21 +18,11 @@ Contributor(s): ______________________________________. package org.thdl.tib.scanner; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.GridLayout; -import java.awt.Menu; -import java.awt.MenuBar; -import java.awt.MenuItem; -import java.awt.TextArea; -import java.awt.TextComponent; -import java.awt.Toolkit; +import java.awt.*; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.Transferable; -import java.awt.event.ActionEvent; -import java.awt.event.FocusEvent; +import java.awt.event.*; import java.io.IOException; import javax.swing.JOptionPane; @@ -145,7 +135,13 @@ public class SwingWindowScannerFilter extends WindowScannerFilter mnuDicts=null; mb.add(m); - + m = new Menu("Tools"); + mnuTranslate = new MenuItem ("Translate"); + mnuTranslate.setShortcut(new MenuShortcut(KeyEvent.VK_T)); + mnuTranslate.addActionListener(this); + m.add(mnuTranslate); + mb.add(m); + m = new Menu("Help"); for (int i = 0; i < DuffScannerPanel.keybdMgr.size(); i++) @@ -191,6 +187,7 @@ public class SwingWindowScannerFilter extends WindowScannerFilter //else mainWindow.setSize(500,600); mainWindow.show(); mainWindow.toFront(); + sp.setFocusToInput(); if (!ThdlOptions.getBooleanOption(AboutDialog.windowAboutOption)) { @@ -323,6 +320,10 @@ public class SwingWindowScannerFilter extends WindowScannerFilter } } + else if (clicked == mnuTranslate) + { + sp.translate(); + } else { if (objModified==null) return; diff --git a/source/org/thdl/tib/scanner/WindowScannerFilter.java b/source/org/thdl/tib/scanner/WindowScannerFilter.java index f95459d..e2ed268 100644 --- a/source/org/thdl/tib/scanner/WindowScannerFilter.java +++ b/source/org/thdl/tib/scanner/WindowScannerFilter.java @@ -54,7 +54,7 @@ public abstract class WindowScannerFilter implements WindowListener, FocusListen protected static String defaultOutputRows = "thdl.scanner.output-pane.rows"; protected ScannerPanel sp; - protected MenuItem mnuExit, mnuCut, mnuCopy, mnuPaste, mnuDelete, mnuSelectAll, mnuAbout, mnuClear, mnuOpen, mnuPreferences, mnuSavePref; + protected MenuItem mnuExit, mnuCut, mnuCopy, mnuPaste, mnuDelete, mnuSelectAll, mnuAbout, mnuClear, mnuOpen, mnuPreferences, mnuSavePref, mnuTranslate; protected CheckboxMenuItem mnuDicts; protected Object objModified; protected AboutDialog diagAbout;