LibreOffice / noa-libre

UNO API of LibreOffice easy and understandable - Nice Office Access
GNU Lesser General Public License v2.1
37 stars 21 forks source link

Double focus problem with Swing #16

Open spike83 opened 7 years ago

spike83 commented 7 years ago

I got a prblem when using noa-libre with Swing. When I'm focusing the Writer and typing and then klick on swing component like JTextField there are two cursors blinking one in Writer and another in JTextField. Text input is appended to the writer.

This happens with Java > 1.6 on Windows even with the latest Java 1.8 and latest LibreOffice 5.2.6.2.

I used the SimpleApp and added the JTextField to demonstrate:

    noaPanel = new JPanel();
    JTextField field = new JTextField();
    getContentPane().add(noaPanel);
    getContentPane().add(field);

The problem does not appear with Java 6.

Any ideas how to fix or work around.

lfcnassif commented 5 years ago

Hi, I also have this issue. Currrently I am using the workaround below:

private int delta = 1;

public void releaseFocus() {
    if (officeFrame != null) {
      try {
        officeFrame.getXFrame().getContainerWindow().setVisible(false);
        officeFrame.getXFrame().getContainerWindow().setVisible(true);
        noaPanel.setSize(noaPanel.getWidth() + delta, noaPanel.getHeight());
        delta *= -1;
      } catch (Exception e) {
      }
    }
}