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

Handle doble click in Writer

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


Joined: 15 Apr 2012
Posts: 22

PostPosted: Tue Apr 17, 2012 5:25 pm    Post subject: Handle doble click in Writer Reply with quote

I want to handle double click on placeholder and show my dialog(instead of standart) , how to do that?

I write this(see below), but office crashed without notification

sub bindMouseDoubleClickHandler
dim clkHandler
clkHandler = createUnoListener( "cbMouseClick_", "com.sun.star.awt.XMouseClickHandler")
ThisComponent.CurrentController.addMouseClickHandler(clickHandler)
end sub

'Function cbMouseClick_mousePressed( aEvent ) As Boolean
' cbMouseClick_mousePressed = TRUE
' print "clicked"
'End Function

'Function cbMouseClick_mouseReleased( aEvent ) As Boolean
' cbMouseClick_mouseReleased = TRUE
' If aEvent.ClickCount = 2 And aEvent.Buttons = 1 Then
' print "clicked"
' end if
'End Function
Back to top
View user's profile Send private message
lx
General User
General User


Joined: 15 Apr 2012
Posts: 22

PostPosted: Tue Apr 17, 2012 5:35 pm    Post subject: Reply with quote

Rewrite and thats work fine:

sub bindMouseDoubleClickHandler
dim handler
handler = createUnoListener( "doubleClickHandler_", "com.sun.star.awt.XMouseClickHandler")
ThisComponent.CurrentController.addMouseClickHandler(handler)
end sub

function doubleClickHandler_mousePressed(event) as boolean
' print "clicked"
doubleClickHandler_mousePressed = true
End Function

function doubleClickHandler_mouseReleased(event) as boolean
If event.ClickCount = 2 And event.Buttons = 1 Then
print "double clicked"
end if

doubleClickHandler_mouseReleased = true
end function
Back to top
View user's profile Send private message
lx
General User
General User


Joined: 15 Apr 2012
Posts: 22

PostPosted: Tue Apr 17, 2012 5:43 pm    Post subject: Reply with quote

Really, if we just do that:


sub bindMouseDoubleClickHandler
dim handler
handler = createUnoListener( "doubleClickHandler_", "com.sun.star.awt.XMouseClickHandler")
ThisComponent.CurrentController.addMouseClickHandler(handler)
end sub

function doubleClickHandler_mousePressed(event) as boolean
doubleClickHandler_mousePressed = true
end Function

function doubleClickHandler_mouseReleased(event) as boolean
doubleClickHandler_mouseReleased = true
end function


as result - > mouse behavior disappear(selection text, position picking by mouse etc)
how to solve that?
Back to top
View user's profile Send private message
lx
General User
General User


Joined: 15 Apr 2012
Posts: 22

PostPosted: Tue Apr 17, 2012 6:32 pm    Post subject: Reply with quote

Pytonyak rocks!

Option Explicit

Global oDocView As Object
Global oMouseClickHandler As Object

Sub RegisterMouseClickHandler
oDocView = ThisComponent.currentController
oMouseClickHandler = _
createUnoListener("MyApp_", "com.sun.star.awt.XMouseClickHandler")
' writedbginfo oMouseClickHandler
oDocView.addMouseClickHandler(oMouseClickHandler)
End Sub

Sub UnregisterMouseClickHandler
on error resume next
oDocView.removeMouseClickHandler(oMouseClickHandler)
on error goto 0
End Sub

Sub MyApp_disposing(oEvt)
End Sub

Function MyApp_mousePressed(oEvt) As Boolean
MyApp_mousePressed = False
End Function

Function MyApp_mouseReleased(oEvt) As Boolean
Dim sMsg As String
With oEvt
sMsg = sMsg & "Modifiers = " & .Modifiers & Chr(10)
sMsg = sMsg & "Buttons = " & .Buttons & Chr(10)
sMsg = sMsg & "X = " & .X & Chr(10)
sMsg = sMsg & "Y = " & .Y & Chr(10)
sMsg = sMsg & "ClickCount = " & .ClickCount & Chr(10)
sMsg = sMsg & "PopupTrigger = " & .PopupTrigger '& Chr(10)
'sMsg = sMsg & .Source.dbg_Methods
End With

ThisComponent.text.string = sMsg

MyApp_mouseReleased = False
End Function

http://pitonyak.org/AndrewMacro.odt
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