Kwame
Kwame

Reputation: 1097

smartgwt position of mouse event

I'm trying to position a context menu in a Smart GWT Canvas, by using ` addRecordClickHandler(new RecordClickHandler() {

            public void onRecordClick(RecordClickEvent event) {
                                    getContextMenu.setRect(rect)
                getContextMenu().show();

            }
        });

`

The problem is that theres doesn't seem to be a straightforward way to get the X/Y coordinates of my mouse click event, which I can use to create the rect. I can get the AbsoluteTop & absoluteLeft of the enclosing Canvas, but that doesn't help me position the context menu window accurately.

Upvotes: 1

Views: 1491

Answers (1)

Kimi
Kimi

Reputation: 6289

RecordClickEvents are usually used with ListGrids. With a Canvas you can use ClickEvent, which has getX() and getY() methods.

addClickHandler(new ClickHandler() {            
    @Override
    public void onClick(ClickEvent event) {
        int x = event.getX();
        int y = event.getY();
    }
});

Upvotes: 2

Related Questions