Nope, when I right click on a column header, it doesn’t actually select a record, right? It should just trigger the onRightClick method and give the x and y coordinates of the mouse pointer.
Let’s say if I select the 5th record from the top, and then perform a right click on the header, I should retrieve the X and Y coordinates near the column header and not of the selected record. Is this a Servoy limitation? Is there a workaround on this?
I want to rightclick on a table-view and showup a popmenu on the mouse position.
So I do this:
var vObject = java.awt.MouseInfo.getPointerInfo().getLocation()
var x = vObject.x
var y = vObject.y
vPopupmenu.show(x,y);
It works (sort of) when I have the window of the smart-client maximized!
but it goes totally wrong when run the smart-client in a smaller window. The position of where the popupmenu appears, is totally different
So I believe this function, returns the x and y position of the whole screen, instead of relative inside the servoy solution.
I do not know if it solves Your issue, but I needed this functionality for buttons.
To show a dialogue on the button position ( even if the solution window is small).
I use the It2Be tools plugin :
// Get the x coordinate of the element relative to the screen...
var button = elements.button;
// calculate the new x coordinate for the dialog.
var x = plugins.it2be_tools.getScreenX(button) - button.getLocationX();
// calculate the new y coordinate for the dialog.
var y = plugins.it2be_tools.getScreenY(button) + button.getHeight() - button.getLocationY();
application.showFormInDialog(forms.name, x, y);
Hans, I tried that but it’s not working, I got the same issue, as I described above.
function showActionMenu(vEvent)
{
var vPopupmenu = plugins.window.createPopupMenu()
var vMenuItem1 = vPopupmenu.addMenuItem('i18n:1.markasread', startAction, 'media:///envelope_open.gif')
var vMenuItem2 = vPopupmenu.addMenuItem('i18n:1.markasunread', startAction, 'media:///envelope_closed.gif')
// var vMenuItem3 = vPopupmenu.addMenuItem('-')
// var vMenuItem4 = vPopupmenu.addMenuItem('i18n:1.archive1', startAction, 'media:///folder_into.png')
// var vMenuItem5 = vPopupmenu.addMenuItem('i18n:1.delete', startAction, 'media:///delete2_16.png')
vMenuItem1.selected = true
// To transfer the right element and formname triggers you have to set them as arguments
vMenuItem1.methodArguments = [1];
vMenuItem2.methodArguments = [2]
// vMenuItem4.methodArguments = [3]
// vMenuItem5.methodArguments = [4]
// Get the x coordinate of the element relative to the screen...
var button = elements[vEvent.getElementName()]
// calculate the new x coordinate for the dialog.
var x = plugins.it2be_tools.getScreenX(button) - button.getLocationX();
// calculate the new y coordinate for the dialog.
var y = plugins.it2be_tools.getScreenY(button) + button.getHeight() - button.getLocationY();
var vSource = vEvent.getSource()
if (vSource != null) {
vPopupmenu.show(x,y);
}
}
I am happy to announce the immediate availability of the MousePointer plugin (my first Servoy plugin! )
A big thank you to Patrick Talbot for answering my questions and for signing the jar for me.
You can find the plugin (and demo solution) on ServoyForge.
Patrick Talbot strikes again!
He created a patch for the window plugin (for the 5.2, 6.0 and 6.1 branch!) and it works great (I just tested this)!
Go vote for it (on the ticket) to have Servoy actually implement this patch !
It will in fact nullify my MousePointer plugin, all you will need is this new Window plugin version (when implemented by Servoy).