Jump to content

mouse position


jahlxx

Recommended Posts

Hi.

 

I have a unipanel, with a custom button.

 

The action of the button, is popup a menu with some options.

 

When click the button on the panel header, the menu popup ok, but I can't control its position on the screen.

 

I'd like it to be shown at the same position of the button, but I don't know how.

 

I've tried with GetCursorPos and Mouse.CursorPos, but the menu is shown in a wrong place, never where I want.

 

Any idea?

 

Thanks.

 

Link to comment
Share on other sites

Maybe you wanted like this?!:

 

related with: http://forums.unigui.com/index.php?/topic/6947-panel-header-icons-tools/

function beforeInit(sender, config)
{
    config.tools = [{
        type: 'gear',
        handler: function(e) {
            ajaxRequest(sender, "_gear", ["x="+e.browserEvent.clientX, "y="+e.browserEvent.clientY])
        }
    }, {
        type: 'pin'
    }];
}
procedure TMainForm.UniPanel1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
var
  x, y: Integer;
begin
  if EventName = '_gear' then
  begin
    x := StrToInt(Params.Values['x']);
    y := StrToInt(Params.Values['y']);
    UniPopupMenu1.Popup(x, y);
  end;
end;
Link to comment
Share on other sites

  • 1 year later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...