More complicated offshoot
The attached Writer document tested on OO is what I ended up with
A blank area should be added to the far left of the status bar on opening. Clicking with the mouse will show a message box of the modifier keys pressed. It will continue to work after a switch to full screen and back.
Could perhaps be used if someone wanted a minimal interface with just the status bar showing but wanted to add some more click options to it.
Just experimenting... usual use at own risk caveat...
(Paint listener was unsuccessful)
Code:
Code: Select all
REM ***** BASIC *****
Sub StartLayoutManagerEventListener 'RUNS ON DOCUMENT VIEW CREATED EVENT
dim lm,el
'LAYOUT MANAGER LISTENER NEEDED SEE BELOW FOR WHY
lm= thiscomponent.currentcontroller.frame.layoutmanager
LML = createUnoListener("StatusLM_", "com.sun.star.frame.XLayoutManagerListener")
lm.addLayoutManagerEventListener(LML)
el= lm.getElement("private:resource/statusbar/statusbar")
'ADD STATUS BAR AREA IF NOT ALREADY THERE
if el.realinterface.accessiblecontext.getaccessiblechild(0).getTitledBorderText <>"" then
dim props(1) as new com.sun.star.beans.PropertyValue
props(0).name = "CommandURL"
props(0).value ="vnd.sun.star.script:Standard.Module1.Test?language=Basic&location=document"
props(1).name = "Width"
props(1).value =20
sett = el.getsettings(true)
sett.insertbyindex(0,props)
el.setsettings(sett)
el.updatesettings
end if
if lm.isElementVisible("private:resource/statusbar/statusbar") =true then setElMouseHandler(el)
end sub
sub StatusLM_disposing(ev)
end sub
'WE NEED LAYOUT MANAGER LISTENER IN CASE STATUS BAR DISPOSED AND RESHOWN - WE NEED TO
'ADD THE MOUSE LISTENER AGAIN IF THAT HAPPENS
'THERE'S NO WAY TO KNOW IF THE LISTENER IS STILL RUNNING SO I'VE USED MODIFYING THE
'FOREGROUND COLOR TO JUST OFF BLACK AS A WAY OF MARKING THE STATUS BAR AS RUNNING THE LISTENER
sub StatusLM_layoutEvent(ev)
dim lm,el,oMouseClickHandler,sett
lm = ev.source
if lm.isElementVisible("private:resource/statusbar/statusbar") =true then
el= lm.getElement("private:resource/statusbar/statusbar")
if el.realinterface.AccessibleContext.foreground <> rgb(1,1,1) then setElMouseHandler(el)
end if
end sub
sub setElMouseHandler(el)
el.realinterface.setforeground rgb(1,1,1)
oMouseClickHandler = createUnoListener("StatusM_", "com.sun.star.awt.XMouseListener")
el.realinterface.addMouseListener (oMouseClickHandler)
end sub
'CAPTURE MOUSE EVENTS FOR AREA
Sub StatusM_mouseEntered(ev) 'mouse listener
end sub
Sub StatusM_mouseExited(Ev)
end sub
Sub StatusM_disposing(Ev)
End Sub
Function StatusM_mousePressed(Ev) As Boolean
if ev.x<20 then
msgbox ev.modifiers
StatusM_mousePressed = true
end if
End Function
Function StatusM_mouseReleased(Ev) As Boolean
end function
sub Test()
msgbox "Double Click works without any listeners"
end sub