N00b at LO macros and LO Basic. Was working on a macro but couldn’t figure out the following:
- How to send a prompt message to the status bar. Is it even possible?
- How to “Await” for a mouse click to select a shape within in the current frame
- Do I really need to add mouse click listeners? Shouldn’t they be on by default as any document needs mouse click when the document is loaded?
Below is my code (help taken from Andrew Pitonyak’s reference). However, it doesn’t await for any input and I always get the “Couldn’t get the mouse click” message (as programmed in the if statement).
REM ***** BASIC ***** Global vLine_selection_listener Global vLine_selection_broadcast Sub MyMacroMain Dim oEventObject as New com.sun.star.awt.MouseEvent StartListeningToMouseClickEvents Line_selection_select(oEventObject) StopListeningToMouseClickEvents End Sub Sub StartListeningToMouseClickEvents vLine_selection_broadcast = ThisComponent.getCurrentController vLine_selection_listener = CreateUnoListener("Line_selection_", "com.sun.star.awt.XMouseClickHandler") vLine_selection_broadcast.addMouseClickHandler(vLine_selection_listener) End Sub Sub StopListeningToMouseClickEvents vLine_selection_broadcast.removeMouseClickHandler(vLine_selection_listener) End Sub Sub Line_selection_select(vEvent) Dim vCurrentSelection As Object vCurrentSelection = vEvent.source If vEvent.Buttons AND com.sun.star.awt.MouseButton.LEFT Then Msg = Msg & "LEFT " Else Msg = "Couldn't get the mouse click" End If MsgBox Msg End Sub Sub Line_selection_disposing(vEvent) 'disposing listener End Sub