Apply XMouseMotionHandler to the sheet

Keyboard macros or custom scripts

Apply XMouseMotionHandler to the sheet

Postby tagetes » Sun Mar 17, 2013 7:11 pm

Good day.
I want to prohibit the use drag & drop tool on a sheet of Calc. I think “:: com :: sun :: star :: awt :: XMouseMotionHandler“ is suitable for this. But I don't know how to take advantage of. Help apply XMouseMotionHandler to the sheet . Fix my code.

Code: Select all   Expand viewCollapse view
Global oDocView_m As Object
Global oMouseMotionHandler As Object

Sub RegisterMouseMotionHandler
     oDocView_m = ThisComponent.CurrentController.Frame.ContainerWindow
     oMouseMotionHandler = createUnoListener("MyApp_", "com.sun.star.awt.XMouseMotionHandler")
     oDocView_m.addMouseMotionListener(oMouseMotionHandler)
     msgbox "RegisterMouseMotionHandler!"
End Sub

Sub UnregisterMouseMotionHandler
     on error resume next
     oDocView_m.removeMouseMotionListener(oMouseMotionHandler)
     on error goto 0
End Sub

Function MyApp_mouseDragged(oEvt) As Boolean
     msgbox "mouseDragged!"
     MyApp_mouseDragged = False
End Function

Function MyApp_mouseMoved(oEvt) As Boolean
     msgbox "mouseMoved!"
     MyApp_mouseMoved = False
End Function


Why don't I see the message "mouseDragged!" and "mouseMoved!" ?
OpenOffice 2.3 / OpenOffice 3.0 / OpenOffice 3.2 on Win 7 / Win XP / Win 98
tagetes
 
Posts: 4
Joined: Wed Mar 13, 2013 6:29 am

Re: Apply XMouseMotionHandler to the sheet

Postby mcmurchy1917 » Thu Mar 21, 2013 11:05 pm

Try this

Global oDocView_m As Object
Global oMouseMotionHandler As Object

Sub RegisterMouseMotionHandler

oDocView_m = ThisComponent.CurrentController.Frame.ComponentWindow
oMouseMotionHandler = createUnoListener("MyApp_", "com.sun.star.awt.XMouseMotionListener")
msgbox "RegisterMouseMotionHandler!"

addremoveMouseMotionListenerRecursively(true, oMouseMotionHandler, oDocView_m)

End Sub

Sub UnregisterMouseMotionHandler
on error resume next
addremoveMouseMotionListenerRecursively(false, oMouseMotionHandler, oDocView_m)
on error goto 0
End Sub

Function MyApp_mouseDragged(oEvt) As Boolean
msgbox "mouseDragged!"
MyApp_mouseDragged = False
End Function

Function MyApp_mouseMoved(oEvt) As Boolean
msgbox "mouseMoved!"
MyApp_mouseMoved = False
End Function


sub addremoveMouseMotionListenerRecursively( bAdd as Boolean, oMouseMotionListener as object, oWin as object)

if bAdd then
oWin.addMouseMotionListener(oMouseMotionListener)
else
oWin.removeMouseMotionListener(oMouseMotionListener)
endif

if HasUnoInterfaces(oWin, "com.sun.star.awt.XVclContainer") then
oWindows = oWin.Windows
for k=0 to UBound(oWindows)
call addremoveMouseMotionListenerRecursively( bAdd, oMouseMotionListener, oWindows(k))
next k
endif

end sub
Slackware user
mcmurchy1917
 
Posts: 22
Joined: Fri Feb 22, 2013 2:15 pm


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest