Skip to content

ChartViewer constructor with contextMenuEnabled parameter seems that is not working #20

@mehdimonemi

Description

@mehdimonemi

Hello @jfree ,
I realized that when I am constructing a new ChartViewer like the bellow:
this.chartViewer = new ChartViewer(chart, false);
the context menu is still not disabled on the chart. I look into the source code and looks like contextMenuEnabled field has not been used.

public ChartViewer(JFreeChart chart, boolean contextMenuEnabled) {
        this.canvas = new ChartCanvas(chart);
        this.canvas.setTooltipEnabled(true);
        this.canvas.addMouseHandler(new ZoomHandlerFX("zoom", this));
        this.setFocusTraversable(true);
        this.getChildren().add(this.canvas);
        this.zoomRectangle = new Rectangle(0.0D, 0.0D, new Color(0.0D, 0.0D, 1.0D, 0.25D));
        this.zoomRectangle.setManaged(false);
        this.zoomRectangle.setVisible(false);
        this.getChildren().add(this.zoomRectangle);
        this.contextMenu = this.createContextMenu();
        this.setOnContextMenuRequested((event) -> {
            this.contextMenu.show(this.getScene().getWindow(), event.getScreenX(), event.getScreenY());
        });
        this.contextMenu.setOnShowing((e) -> {
            this.getCanvas().setTooltipEnabled(false);
        });
        this.contextMenu.setOnHiding((e) -> {
            this.getCanvas().setTooltipEnabled(true);
        });
    }

How can I disable context menu in this case?
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions