Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    MouseMoveEvent and Legend rectangle

    Is there a way to check if a MouseMoveEvent's coordinates are in the FacetChart Legend rectangle?

    For example, something like...

    Code:
            addMouseMoveHandler(new MouseMoveHandler() {
                @Override
                public void onMouseMove(MouseMoveEvent event) {
                    if ([B]legendDrawRect[/B].isInBounds(event.getX(), event.getY())) {
                        // DO SOMETHING
                    }
                }
            });
    Thanks

    SmartClient Version: v9.1p_2014-08-19/Pro Deployment (built 2014-08-19)
    Last edited by stonebranch2; 22 Aug 2014, 13:03. Reason: Fixed the CODE tag and noted this was regarding "FacetChart"'s

    #2
    There's isn't currently an accessor that would get you the exact legend rect - you would basically have to figure it out based on the chart rect and the various margin settings.

    However did you notice there is already a LegendHover event? Depending on what you are trying to do, you may be able to use that instead of starting from mouseMove.

    Comment


      #3
      What I am trying to do is avoid my hover for a pie slice from showing when the mouse moves over the legend rectangle, as this causes some confusion when the hover appears for a particular slice and the mouse is over an unrelated legend swatch. I do like how the hover for a pie slice appears when hovering on the whitespace outside of a particular slice (i.e by utilizing getNearestDrawnValue()), however, if the mouse moves over the legend rectangle, I want to hide the hover.

      In lieu of an accessor for the legend rect, I am using the following logic which seems to accurately detect when the mouse hovers over the legend rectangle.

      Code:
      Integer margin = getMargin();
      if (margin == null) margin = 0;
      int left = (int) getChartLeftAsDouble();
      int top = (int) getChartTopAsDouble();
      int width = (int) getChartWidthAsDouble(false);
      int height = (int) getChartHeightAsDouble(false);
      DrawRect r = new DrawRect();
      r.setRect(left, top, width + margin.intValue(), height + margin.intValue());
      if (!r.isInBounds(getOffsetX(), getOffsetY())) return; // Do not show hover.
      Thanks
      Last edited by stonebranch2; 25 Aug 2014, 06:51. Reason: Added the chart margin into the calculation.

      Comment

      Working...
      X