70002168 The double click event fires with single click when cmdTextEdit is active

Article 70002168
Type HowTo
Product Engine
Version 8
Date Added 2/17/2022 12:00:00 AM
Fixed 10.1001.0.1 (2/17/2022 12:00:00 AM)
Submitted by Francesco Rullo


The double-click event fires with single click when a command like cmdTextEdit is active. Try it using a code like: private void Form9_Load(object sender, EventArgs e) { doc = vdFramedControl1.BaseControl.ActiveDocument; doc.CommandAction.CmdText("hello", new gPoint(2, 2), 0.0d); vdFramedControl1.BaseControl.vdMouseDoubleClick += new MouseDoubleClickEventHandler(BaseControl_vdMouseDoubleClick); //vdFramedControl1.BaseControl.vdMouseClick += new MouseClickEventHandler(BaseControl_vdMouseClick); } int ddkk=0; void BaseControl_vdMouseDoubleClick(MouseEventArgs e, ref bool cancel) { ddkk++; this.Text = "double click " + ddkk.ToString() + " " + e.Clicks.ToString(); vdText mytxt = (vdText)doc.Model.Entities[doc.Model.Entities.Count - 1]; if (mytxt == null) return; doc.CommandAction.CmdTextEdit(mytxt); }


Such code as above will execute the cmdTextEdit BEFORE finishing the double-click event code so every click that you do while the command is active inside the double-click will have this problem! In order to bypass this you need to use the PostExecuteCommand event and call the edit text command in this event. See code below:

    vdFramedControl.BaseControl.vdMouseDoubleClick += new VectorDraw.Professional.Control.MouseDoubleClickEventHandler(BaseControl_vdMouseDoubleClick);

    void BaseControl_vdMouseDoubleClick(MouseEventArgs e, ref bool cancel)

    void CommandLine_CommandExecute(string commandname, bool isDefaultImplemented, ref bool success)
            if (string.Compare(commandname, "Mycommand", true) == 0)
                success = true;
                //Get mouse position in User CS  (Current coordinate system)
                gPoint oCursorPos = vdFramedControl.BaseControl.ActiveDocument.CCS_CursorPos(); // this is in USER coord. System, not in World CS

                //Transform mouse position from USER CS to WorldCS
                gPoint oCursorPosPixel_world = vdFramedControl.BaseControl.ActiveDocument.User2WorldMatrix.Transform(oCursorPos);
                //Transform mouse position from WorldCS to pixels
                gPoint oCursorPosPixel = vdFramedControl.BaseControl.ActiveDocument.World2PixelMatrix.Transform(oCursorPosPixel_world);

                //Convert to use GetEntityFromPoint
                System.Drawing.Point oCursorPosPoint = new System.Drawing.Point((int)oCursorPosPixel.x, (int)oCursorPosPixel.y);

                //Get the entity inside the Viewport (model entity)
                vdFigure vFigure = vdFramedControl.BaseControl.ActiveDocument.ActiveLayOut.GetEntityFromPoint(oCursorPosPoint,vdFramedControl.BaseControl.ActiveDocument.ActiveLayOut.Render.GlobalProperties.PickSize, false);
                if (vFigure is vdText || vFigure is vdMText)

Send comments on this topic.