OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Key Press or Mouse click in Java

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Agnisys
Power User
Power User


Joined: 10 May 2008
Posts: 58
Location: Noida, India

PostPosted: Wed Oct 22, 2008 3:56 am    Post subject: Key Press or Mouse click in Java Reply with quote

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
View user's profile Send private message
doxatesting1
General User
General User


Joined: 23 Oct 2008
Posts: 5

PostPosted: Tue Oct 28, 2008 6:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
jpatokal
Newbie
Newbie


Joined: 13 Jun 2010
Posts: 2

PostPosted: Sun Jun 13, 2010 9:48 pm    Post subject: Reply with quote

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
View user's profile Send private message
hassan83
Newbie
Newbie


Joined: 28 Mar 2012
Posts: 2

PostPosted: Wed Mar 28, 2012 4:53 am    Post subject: Its working in Live Mode but not in design Mode Reply with quote

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..... Sad
_________________
hassan.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group