| View previous topic :: View next topic |
| Author |
Message |
Agnisys Power User

Joined: 10 May 2008 Posts: 58 Location: Noida, India
|
Posted: Wed Oct 22, 2008 3:56 am Post subject: Key Press or Mouse click in Java |
|
|
Hello,
1. How to detect Key Press or Mouse click on a Writer Document in Java code.
OR
2. How to attach a Basic Macro to a form component in Java.
I know we can select the design mode and double click on a component and assign a macro Basic macro to many events. But is that possible to do in Java code?
Any pointers to any of these issues would be very much appreciated.
Thanks,
Anupam _________________ Using OO 2.4, NetBeans6.1, Java 1.6u6 |
|
| Back to top |
|
 |
doxatesting1 General User

Joined: 23 Oct 2008 Posts: 5
|
Posted: Tue Oct 28, 2008 6:27 pm Post subject: |
|
|
Hi, Agnisys,
try the code below for your question 1
| Code: | XDrawPageSupplier drawPageSupplier = (XDrawPageSupplier) UnoRuntime.queryInterface(XDrawPageSupplier.class, xTextDocument);
XShapes shapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, drawPageSupplier.getDrawPage());
for (int i = 0; i < shapes.getCount(); i++) {
XControlShape shape = (XControlShape) UnoRuntime.queryInterface(XControlShape.class, shapes.getByIndex(i));
if (shape == null) {
continue;
}
XControlModel model = shape.getControl();
if (model == null) {
continue;
}
XController controller = bean.getFrame().getController().getModel().getCurrentController();
XControlAccess xCtrlAcc = (XControlAccess) UnoRuntime.queryInterface(XControlAccess.class, controller);
XControl control = xCtrlAcc.getControl(model);
XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, control);
MyMouseListener mouseListener = new MyMouseListener();
xWindow.addMouseListener(mouseListener);
}
private class MyMouseListener implements XMouseListener {
public void disposing(EventObject oEvent) {}
public void mousePressed(MouseEvent ev) {}
public void mouseReleased(MouseEvent ev) {}
public void mouseEntered(MouseEvent ev) {}
public void mouseExited(MouseEvent ev) {}
} |
|
|
| Back to top |
|
 |
jpatokal Newbie

Joined: 13 Jun 2010 Posts: 2
|
Posted: Sun Jun 13, 2010 9:48 pm Post subject: |
|
|
| This doesn't work for me: when I run it in the initialize block of my extension, shapes.getCount() is zero, so it doesn't even try to set the listeners. Am I missing something? |
|
| Back to top |
|
 |
hassan83 Newbie

Joined: 28 Mar 2012 Posts: 2
|
Posted: Wed Mar 28, 2012 4:53 am Post subject: Its working in Live Mode but not in design Mode |
|
|
Hi,
The doxatesting1 your code solved my issues, thanks.
But its not working in design mode....
I knew some body knew how to fix this...
but any body please help.....  _________________ hassan. |
|
| Back to top |
|
 |
|