Article | 70002651 |
Type | Wish |
Product | WebJS |
Version | 1103 |
Date Added | 3/12/2025 12:00:00 AM |
Fixed | 11.4.1 (3/13/2025 12:00:00 AM) |
Submitted by | Brendan Fry |
Summary
A method to get the grip indexes from a point on the webcontrol
Solution
In version 11.4.1 a new method vdcanvas.GripManager.GetGripIndexesFromPoint was exported
Returns an array contains the entities with their grip indices that exists over the passed point
param name="x" : X position in pixel
param name="y" : Y position in pixel
Returns: An array contains the entities with their grip indices that exists over the passed point.
Each item of the array is an array of two items [fig,indexes], fig is the entity and indexes is a zero based array of grip indicies of the entity under the passed x,y position.
If no grips are under the passed position returns an empty (zero length) array
Example:
//overwrite the vdmousedown event //so when no user action is started and the user click over an entity we change its color to red //except when user click over a grip we do nothing and let the default web control implemantation to begin a movegrip action var vdcanvas; function vdrawInitPageLoad() { vdcanvas = vdmanager.AttachCanvas('canvas'); vdcanvas.GripManager.GripColor = [255, 255, 0, 255]; vdcanvas.GripManager.GripSize = 13; vdcanvas.GripManager.SelectMode = vdConst.GRIPMODE_AUTO | vdConst.GRIPMODE_SINGLE; vdcanvas.vdmousedown = _vdmousedown; } function _vdmousedown(args) { var grips =[]; var vdrawobj = args.target; var action = vdrawobj.ActiveAction(); if (args.mousebutton == 1 && !action.IsStarted()) {//check grips only if left mouse button down and no action is started(only the default action is active) grips = vdrawobj.GripManager.GetGripIndexesFromPoint(args.xPix, args.yPix); } if (grips.length == 0) {//if no gris under the mouse var fig = vdrawobj.GetEntityFromPoint(args.xPix, args.yPix);//scan if an entity is clicked if (fig) { //change the entity color to red and refresh the drawing view fig.PenColor = vdConst.colorFromString("255,0,0"); vdrawobj.UpdateFig(fig); //update drawing view action.hide(); vdrawobj.DrawEntity(fig); action.show(); } }//else the default vdraw action is evaluate }