How to Detect user pressing Esc key during sendcommand combine pause?

How to Detect user pressing Esc key during sendcommand combine pause?

AU-Techniques
Contributor Contributor
904 Views
2 Replies
Message 1 of 3

How to Detect user pressing Esc key during sendcommand combine pause?

AU-Techniques
Contributor
Contributor

Hi, I have read some Post such as: 

https://adndevblog.typepad.com/autocad/2013/02/return-to-command-prompt-when-escape-is-pressed-using...

https://adndevblog.typepad.com/autocad/2012/07/allowing-users-to-escape-from-long-operations-in-auto...

and some other posts but have yet to find a solution to detect when the user press esc while sendcommand combine editor.pausetoken. This is my code example:

ed.Command("._mirror", sset, "", pt1, Editor.PauseToken, "No")

Instead of selecting the second point, the user has pressed esc.

The current I am using is way of comparison the ID of the last entity before and after using the mirror command, but the problem is that the editor.pausetoken is not canceled seem to have an effect on another new command when called. 

Can you give me a better solution?

Thanks in advance.

 

 

0 Likes
Accepted solutions (1)
905 Views
2 Replies
Replies (2)
Message 2 of 3

_gile
Consultant
Consultant
Accepted solution

Hi,

 

Editor.Command() requires all arguments to be defined, while usion Editor.PauseToken you have to use Editor.CommandAsync(). You can read this topic from Kean Walmsley' blog and this thread I started at TheSwamp.

 

try { await ed.CommandAsync("_.mirror", sset, "", pt1, Editor.PauseToken, "_No"); }
catch { Application.ShowAlertDialog("Cancel"); }


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 3

AU-Techniques
Contributor
Contributor

Hi, i have read both your post and kean before and i have tried it but it all failed and now i know why. Exactly the syntax error with async prevented me from doing it. 😉 With your code my project was running as I expected. I like the way it works.Thanks a lot.
Good evening fun. 😃

0 Likes