Skip to main content Skip to footer

How to Set Shapes to Only Move Across One Axis

It is possible to force shapes to only be allowed to move across one axis by overriding the move() method of the GC.Spread.Sheets.Shapes.ShapeUI class. We can do this by passing a constant value for the x or y coordinate arguments of the move() method.

We can override move() by using the following code:

let oldMove = GC.Spread.Sheets.Shapes.ShapeUI.prototype.move;
GC.Spread.Sheets.Shapes.ShapeUI.prototype.move = function (x, y) {
oldMove.apply(this, [x, shape.y()]);
}

This passes a constant value for the y axis argument, but the same can be applied to the x axis. You can view the following sample that showcases the overridden method here (thanks to Ankit Kumar).

Tye Glenz