c2k
2009-09-02 18:48 UTC
Hi,
Does anyone know how to get the command a button performs to repeat by pressing enter at the command line?
What I have noticed is the button executes the command just fine, but if I press enter in order to repeat the command it doesn't repeat the command the button performed, instead it repeats the last command issued before the DCL button was pushed.
Thanks in advance.
owenwengerd
2009-09-02 19:09 UTC
What you describe indicates that the button lost the input focus. At the end of your button's OnClicked event handler, try setting the input focus back to the button to see if that works for you. You may also need to set the form's Keep Focus property.
c2k
2009-09-02 20:17 UTC
I tried setting the focus back in the lisp... didn't work. I had the Visual LISP editor open with it set to animate and after hitting the button it starts the function which in turn issues the first of 3 operations. This operation is an external command that opens a dialog that is not part of the DCL, it is part of a different program. Once I am done in that dialog & press OK to close it, the function continues and issues the second & third operations which set a value to a progress bar on the form & sets a caption on the form. Then the first operation continues by having me select objects in the drawing. FYI, the form is a palette (modeless).
When I add the operation to set the focus back it issues it right after the caption is updated and before the external command has me select objects. So that doesn't work.
I don't think my problem is with the setup of the form, but with AutoCAD not recognizing the function for the button as a command. Does that make sense?
If I manually type the function name for the button and after running it once, hit enter, it executes it again. So it works when manually running the function, but not when it is run from the form. Why would that be?
owenwengerd
2009-09-03 03:00 UTC
The event handler is executed as a lisp function, not as a command, so that is why it doesn't repeat on its own. You could define a second command that contains the button's event handler code, then change the button's event handler to a single dcl_SendString call that executes the new command. This would allow AutoCAD to process the command in the normal way, thus allowing it to be repeated.
c2k
2009-09-03 13:53 UTC
I figured it had to be something like that. So even though in the lisp it is defined with a "c:" as in "(defun c:_OnClicked (/))" it is only sending it as "(defun _OnClicked (/))".
So if my external command is "renumber", instead of issuing "(vl-cmdf "renumber")", I could issue "(dcl_SendString "renumber")"
Thanks for your help. :)
owenwengerd
2009-09-03 14:39 UTC
Actually the event handler is called as e.g. (c:_OnClicked), but you have the right idea. Also, don't forget to append a space or line feed to the end of your command in the call to dcl_SendString.
c2k
2009-09-03 14:46 UTC
author=owenwengerd link=topic=899.msg4491#msg4491 date=1251988745 wrote:
Actually the event handler is called as e.g. (c:_OnClicked), but you have the right idea.
OK, I just copied that out of the help file.
author=owenwengerd link=topic=899.msg4491#msg4491 date=1251988745 wrote:Also, don't forget to append a space or line feed to the end of your command in the call to dcl_SendString.
OK, thanks for the additional info. I will give it a try.
c2k
2009-09-03 15:58 UTC
;D Alright, that worked great! Thanks again. 8)