diff --git a/src/basic/Point.js b/src/basic/Point.js index 56eb1159..f959d4a3 100644 --- a/src/basic/Point.js +++ b/src/basic/Point.js @@ -784,11 +784,19 @@ var Point = Base.extend(/** @lends Point# */{ /** * This property is only present if the point is an anchor or control point * of a {@link Segment} or a {@link Curve}. In this case, it returns - * {@true it is selected} + * {@true if it is selected} * * @name Point#selected * @property - * @return {Boolean} {@true if the point is selected} + * + * @example {@paperscript} + * var path = new Path.Circle({ + * center: [80, 50], + * radius: 40 + * }); + * + * // Select the third segment point: + * path.segments[2].point.selected = true; */ /** diff --git a/src/item/Item.js b/src/item/Item.js index 32239a80..6c504de9 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -1887,7 +1887,7 @@ new function() { // Injection scope for hit-test functions shared with project // See if we should check self (own content), by filtering for type, // guides and selected items if that's required. var checkSelf = !(options.guides && !this._guide - || options.selected && !this.isSelected(true) + || options.selected && !this.isSelected() // Support legacy Item#type property to match hyphenated // class-names. || options.type && options.type !== Base.hyphenate(this._class) diff --git a/src/path/Path.js b/src/path/Path.js index d3ec0df4..de3051a2 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -935,7 +935,7 @@ var Path = PathItem.extend(/** @lends Path# */{ */ isFullySelected: function() { var length = this._segments.length; - return this.isSelected(true) && length > 0 && this._segmentSelection + return this.isSelected() && length > 0 && this._segmentSelection === length * /*#=*/SegmentSelection.ALL; }, diff --git a/src/path/Segment.js b/src/path/Segment.js index 818ea011..e38c3338 100644 --- a/src/path/Segment.js +++ b/src/path/Segment.js @@ -282,16 +282,13 @@ var Segment = Base.extend(/** @lends Segment# */{ } }, - _getSelection: function(point) { - return !point ? /*#=*/SegmentSelection.ALL - : point === this._point ? /*#=*/SegmentSelection.POINT - : point === this._handleIn ? /*#=*/SegmentSelection.HANDLE_IN - : point === this._handleOut ? /*#=*/SegmentSelection.HANDLE_OUT - : 0; + changeSelection: function(flag, selected) { + var selection = this._selection; + this.setSelection(selected ? selection | flag : selection & ~flag); }, /** - * Specifies whether the {@link #point} of the segment is selected. + * Specifies whether the segment is selected. * * @bean * @type Boolean @@ -305,14 +302,12 @@ var Segment = Base.extend(/** @lends Segment# */{ * // Select the third segment point: * path.segments[2].selected = true; */ - isSelected: function(_point) { - return !!(this._selection & this._getSelection(_point)); + isSelected: function() { + return !!(this._selection & /*#=*/SegmentSelection.ALL); }, - setSelected: function(selected, _point) { - var selection = this._selection, - flag = this._getSelection(_point); - this.setSelection(selected ? selection | flag : selection & ~flag); + setSelected: function(selected) { + this.changeSelection(/*#=*/SegmentSelection.ALL, selected); }, /** diff --git a/src/path/SegmentPoint.js b/src/path/SegmentPoint.js index 303483d7..ac5d8cc5 100644 --- a/src/path/SegmentPoint.js +++ b/src/path/SegmentPoint.js @@ -78,11 +78,19 @@ var SegmentPoint = Point.extend({ return Numerical.isZero(this._x) && Numerical.isZero(this._y); }, - setSelected: function(selected) { - this._owner.setSelected(selected, this); + isSelected: function() { + return !!(this._owner._selection & this._getSelection()); }, - isSelected: function() { - return this._owner.isSelected(this); + setSelected: function(selected) { + this._owner.changeSelection(this._getSelection(), selected); + }, + + _getSelection: function() { + var owner = this._owner; + return this === owner._point ? /*#=*/SegmentSelection.POINT + : this === owner._handleIn ? /*#=*/SegmentSelection.HANDLE_IN + : this === owner._handleOut ? /*#=*/SegmentSelection.HANDLE_OUT + : 0; } });