I'm trying to implement multiple cell selection while holding Shift by overriding mouseClicked() in mxGraphControl:

public void mouseClicked( MouseEvent e )
{
   if(event.isShiftDown())
   {
      Object c = getCellAt( e.getX(), e.getY() );
      getGraph().addSelectionCell( c );
   }
}

but selectionCells seems to be empty every time it enters mouseClicked(). where is that cleared? Did I misunderstand how mxGraphSelectionModel works?

asked 17 Apr '12, 11:10

Shuo's gravatar image

Shuo
217
accept rate: 0%

edited 17 Apr '12, 15:48

David's gravatar image

David
4.9k21831


Try overriding mxGraphComponent.isToggleEvent.

link

answered 17 Apr '12, 15:38

Gaudenz's gravatar image

Gaudenz
80.1k1310
accept rate: 39%

that works very well. Thanks !

(17 Apr '12, 15:45) Shuo

FYI, I got this to work in the new (non-Sencha) grapheditor with two overrides:

mxGraph.prototype.isToggleEvent = function(evt) { return mxEvent.isControlDown(evt) || mxEvent.isShiftDown(evt); };

var mxPanningHandlerMouseDown = mxPanningHandler.prototype.mouseDown; mxPanningHandler.prototype.mouseDown = function(sender, me) { var result = mxPanningHandlerMouseDown.apply(this, arguments);

// no popup for shift- events, they will multiselect instead
if (mxEvent.isShiftDown(me.evt))
    this.popupTrigger = false;

};

Also I set

mxPopupMenu.useLeftButtonForPopup = false;

so the popup menu comes up on right-click instead of shift-left-click.

link

answered 30 May '12, 12:42

lannie's gravatar image

lannie
7512
accept rate: 22%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×228
×13
×1
×1
×1

Asked: 17 Apr '12, 11:10

Seen: 1,685 times

Last updated: 30 May '12, 12:42