I know one easy popup window in Basic, but I don’t know how to recalculate the position X,Y from ViewCursor to the PopupWindow coordinates.
Sub showPopup
dim oDoc as object, oWindow as object, oVCur as object
dim aRect as new com.sun.star.awt.Rectangle, oPopup as object, n&, c&
oDoc=ThisComponent
oWindow=oDoc.CurrentController.Frame.ComponentWindow
oVCur=oDoc.CurrentController.ViewCursor 'view cursor
aRect=CreateUnoStruct("com.sun.star.awt.Rectangle")
aRect.X=100 'oVCur.Position.X -> i don't know how to recalculate the coordinates from the ViewCursor
aRect.Y=100 'oVCur.Position.Y
oPopup=CreateUnoService("stardiv.vcl.PopupMenu") 'or com.sun.star.awt.PopupMenu
c=1
oPopup.insertItem(c, "no hello world, it is not so good place for witty living!", 0, c)
oPopup.setCommand(c, "item" & c)
c=2
oPopup.insertItem(c, "it is possible to say bye bye, but what to do thenceforward?", 0, c)
oPopup.setCommand(c, "item" & c)
n=oPopup.execute(oWindow, aRect, com.sun.star.awt.PopupMenuDirection.EXECUTE_DEFAULT)
if n>0 then
msgbox oPopup.getCommand(n)
end if
End Sub