Text document key event

Discussions about using 3rd party extension with OpenOffice.org
Locked
maram.j.a
Posts: 6
Joined: Thu Oct 29, 2020 8:19 am

Text document key event

Post by maram.j.a »

Hello

I am trynig to build an extension for the first time
I am using java and eclips idE
But I am having problem with the key events
I implented the XKeyListener to my main class
And override the methods
But it show me no respons is there somthing other than java implementation I should do to make it work
Pleas help me out
OOo 4.1
win64
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Text document key event

Post by JeJe »

You need to use a keyhandler not a keylistener to override events
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
maram.j.a
Posts: 6
Joined: Thu Oct 29, 2020 8:19 am

Re: Text document key event

Post by maram.j.a »

thank you so much for answering me
i trayed to switch to the XKeyHandler but still not having any respons

@Override
public void disposing(EventObject arg0) {
// TODO Auto-generated method stub

}

@Override
public boolean keyPressed(KeyEvent arg0) {
// TODO Auto-generated method stub
myFrame.Show();
return false;
}

@Override
public boolean keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub
return false;
}
OOo 4.1
win64
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Text document key event

Post by RoryOF »

There is a keyhandler example at
https://jezzper.com/jezzper/discussions ... 65002B1DA8

You will probably have to translate the code to fit your usage.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Text document key event

Post by Villeroy »

Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Text document key event

Post by JeJe »

I don't know Java but here's some code in Basic. You have to return true if you want to stop the event.

Code: Select all


global oXKeyHandler as object

sub StartXKeyHandlerN

	dim oDoc
	oDoc =thiscomponent 
	oXKeyHandler = CreateUnoListener("KeyHandler_", "com.sun.star.awt.XKeyHandler")
	oDoc.CurrentController.AddKeyHandler(oXKeyHandler)
end sub

sub KeyHandler_Disposing(ev)
end sub

function KeyHandler_KeyPressed(ev) as boolean
if ev.keychar = "I" or ev.keychar = "i" then 
KeyHandler_KeyPressed = true
else
KeyHandler_KeyPressed = false
end if

End function

function KeyHandler_KeyReleased(ev) as boolean
end function

Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
maram.j.a
Posts: 6
Joined: Thu Oct 29, 2020 8:19 am

Re: Text document key event

Post by maram.j.a »

the Basic code worked just fine in macro
so i wonder is there any way to call a java method into macro
if not then how can i generate macro that can connect to mysql database
 Edit: Topic locked to prevent fragmentation of discussion because maram.j.a has asked the same question in Calling java method in to OOobasic macro 
OOo 4.1
win64
Mountaineer
Posts: 310
Joined: Sun Sep 06, 2020 8:27 am

Re: Text document key event

Post by Mountaineer »

For the mySQL-Topic you should open a seperate Thread.

I know only the german Version of the Handbook for base,vbut it describes several macros and connections to mySQL.

J.
OpenOffice 3.1 on Windows Vista
Locked