Easy status bar item in Basic
Posted: Fri Sep 08, 2023 5:48 pm
Status bar items need a statusbar controller to function. What we can do in Basic is add a blank area which calls an uno or macro command on a double click.
Edit: you can add a listener to capture a single mouse press or ones with modifiers. Things get awkward though, if for example, in Writer there's a switch to full screen and back - in which case a new status bar looks to be created - with the inserted item and double click function still - but that listener is lost. I lost interest about there and didn't look further to see if a paint listener could be employed for drawing on the blank item as well.
Code: Select all
Sub testAddStatusArea 'customises the current controller's status bar
'uno command example for Writer
AddStatusBarArea ".uno:Bold"
'macro
'macropath = libraryname.modulename.subname
'AddStatusButton "vnd.sun.star.script:" & macropath & "?language=Basic&location=application"
end sub
sub AddStatusBarArea(CommandURL)
dim lm,el,sett, props(2) as new com.sun.star.beans.PropertyValue
lm= thiscomponent.currentcontroller.frame.layoutmanager '.getelements
el= lm.getElement("private:resource/statusbar/statusbar")
props(0).name = "CommandURL"
props(0).value =CommandURL
props(1).name = "Width"
props(1).value =20
sett = el.getsettings(true)
sett.insertbyindex(0,props)
el.setsettings(sett)
el.updatesettings
end sub