Hi,
I’ve just started studying LibreOffice Basic. I have extensively used VBA with Excel, now I would like to export some jobs on LO. The feature I’m struggling to export now is offering a cell context menu (popup menu against R-click) based on the cell content. The first thing I need to understand is how to kill the default context menu, the new popup, in fact, must be prepared on the fly. Here’s what I’ve done and consequent questions:
- With Excel, I’ve done an .xlsm that simply suppresses the context menu in the range c3:f6 (using Worksheet_BeforeRightClick). I’ve loaded with Calc and found it works as expected with the only delta that in Calc the selected cell does not follow the R-Click when inside the C3:F6 range. If i try to save the file ( .xlsm or .odf same effect), the macro does not work any more, popping up the menu also inside the C3:F6 range. Q>> Do I miss something before/during the save? <<
- I’ve found one code example and read the documentation of the objects used in it, in order to implement the above function in native LO Basic. I’ve used “com.sun.star.awt.XMouseClickHandler”:
oMouseClickHandler = createUnoListener(“MouseOnClick_”, “com.sun.star.awt.XMouseClickHandler”)
ThisComponent.getCurrentController().addMouseClickHandler(oMouseClickHandler)
I’ve implemented MouseOnClick_mousePressed with a simple code:
MouseOnClick_mousePressed = true
Exit Function
According to mousePressed() documentation for the XMouseClickHandler, returning TRUE should stop the other handlers waiting to process the event. The right-click pressure is captured, but the default popup is drawn after exiting the function. Q>> Since the original xlsm worked in LO, which interface should I use? <<. Q>> Alternatively: is it a bug in mousePressed()? <<.
Thanks
Stefano