OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: Kerry on January 13, 2010, 04:27:23 PM

Title: Enter to repeat command from a Dialog Menu.
Post by: Kerry on January 13, 2010, 04:27:23 PM

I'm calling any one of several  Functions/Commands from a modeless dialog. ( think of the dialog as a menu)

I want the user to be able to press ENTER after running one instance of the command and have the command repeat.
I recall reading somewhere of a method of forcing the system to recognise the function (SUBR) as the last command run.

I don't want to run MULTIPLE consecetive instances, I want the option of pressing ENTER and have another instance.

For Example : With the MasterDemo Palette when a command button is pressed and the command runs,
THEN ; press ENTER and have the command run again.

Anyone have any ideas ??

Regards
Kerry
Title: Re: Enter to repeat command from a Dialog Menu.
Post by: BazzaCAD on January 13, 2010, 04:46:13 PM
I would love to be able to do that also.
And I thought you would be the one to figure it out and teach us all how to do it . :)
Title: Re: Enter to repeat command from a Dialog Menu.
Post by: Kerry on January 13, 2010, 05:02:54 PM
The most frustrating thing is I seem to recall reading 'somewhere' how to do this.

... problem with being retention challenged that comes with longevity.


ooooohhh
just noticed my post count is 333
... does that have any significance ( half a beast or something :) )
Title: Re: Enter to repeat command from a Dialog Menu.
Post by: owenwengerd on January 13, 2010, 05:22:33 PM
Remove the C: from the OnClicked event handler name so it runs as a command instead of a function.
Title: Re: Enter to repeat command from a Dialog Menu.
Post by: Kerry on January 13, 2010, 05:32:41 PM


Owen,
Sorry, I don't quite get your meaning ??
Title: Re: Enter to repeat command from a Dialog Menu.
Post by: Kerry on January 13, 2010, 05:48:08 PM

Ahhh the penny dropped.

change in the odcl editor , and in the call ..
So that the last command completed is the command I want repeated.

ala
(DEFUN KDUB_CommandCenter_Form_B01_OnClicked (/) (c:KDUB_Steel_Main))
(DEFUN KDUB_CommandCenter_Form_B02_OnClicked (/) (c:kdub_HOLES))

wonderfull !!
Title: Re: Enter to repeat command from a Dialog Menu.
Post by: owenwengerd on January 13, 2010, 07:18:24 PM
The only thing you should have to change is the event handler name in the editor (and to make sure EventInvoke is asynchronous). Your lisp code shouldn't require any changes.
Title: Re: Enter to repeat command from a Dialog Menu.
Post by: Kerry on January 13, 2010, 08:07:24 PM

The button_OnClicked Event function was defined as a command (SUBR)
ie:
(DEFUN C:KDUB_CommandCenter_Form_B01_OnClicked (/) (c:KDUB_Steel_Main))


I changed it to a function (USUBR) in both the code and the Dialog Editor
.. by removing the C: prefix
ie:
(DEFUN KDUB_CommandCenter_Form_B01_OnClicked (/) (c:KDUB_Steel_Main))

now the last registered command completed is  c:KDUB_Steel_Main not the event trap, allowing for ENTER to repeat the command.

//--------------
Is this what you meant ??
It works as I now have it.


Title: Re: Enter to repeat command from a Dialog Menu.
Post by: owenwengerd on January 13, 2010, 08:31:23 PM
You don't need the (defun KDUB_...) as it's not called.
Title: Re: Enter to repeat command from a Dialog Menu.
Post by: Kerry on January 13, 2010, 09:13:07 PM

I thinks we may be talking at cross purposes Owen :)

I do need the error trap function to be able to call the draw routine.

The only way I can see to eliminate the event trap is to call the draw routine directly from the editor ( in place of the event trap function)
... but that won't always suit because in some cases the event trap needs to do some work prior to calling it's draw routine.

Regards
Kerry
Title: Re: Enter to repeat command from a Dialog Menu.
Post by: BazzaCAD on January 13, 2010, 09:43:07 PM
WOW, all these years I wanted to do this & didn't think it was easily possible without a bunch of recoding.
Now I find out it was super easy...
Thanks Owen.  :)

Here's a really basic sample (click the button, then hit Enter as few times)
Title: Re: Enter to repeat command from a Dialog Menu.
Post by: owenwengerd on January 13, 2010, 10:35:42 PM
Quote from: Kerry Brown on January 13, 2010, 09:13:07 PM
I thinks we may be talking at cross purposes Owen :)

That's entirely possible. Assuming you've tested that thesis, what happened when you did what I suggested?
Title: Re: Enter to repeat command from a Dialog Menu.
Post by: Kerry on January 13, 2010, 11:16:14 PM
Quote from: owenwengerd on January 13, 2010, 10:35:42 PM
Quote from: Kerry Brown on January 13, 2010, 09:13:07 PM
I thinks we may be talking at cross purposes Owen :)

That's entirely possible. Assuming you've tested that thesis, what happened when you did what I suggested?

I don't actually know what you suggested. Several of your comments seem contrary to each other.


QuoteRemove the C: from the OnClicked event handler name so it runs as a command instead of a function.
A command by definition HAS the C: a function doesn't. So removing the C: does NOT make it a command.

QuoteThe only thing you should have to change is the event handler name in the editor ...  Your lisp code shouldn't require any changes.
If I change the Name in the Editor and NOT in the Lisp the names won't match ...

QuoteYou don't need the (defun KDUB_...) as it's not called.
This IS what I get when I remove the C: ( refer above )


QuoteThat's entirely possible. Assuming you've tested that thesis, what happened when you did what I suggested?


What DID you actually suggest ?  .. as I said, obviously something other than what I got to work.

Regards
Kerry
Title: Re: Enter to repeat command from a Dialog Menu.
Post by: Kerry on January 13, 2010, 11:22:50 PM
OK,
Is this correct ...


the Event name in the Editor can be a function and the Event name in the Code remains a Command. ??

Whereas I made both names functions.

And the documentation indicates they both be Commands.
Title: Re: Enter to repeat command from a Dialog Menu.
Post by: Danner on January 14, 2010, 01:13:38 AM
Hi

Just in case its of interest - I've been using a slightly clumsier method to allow "enter" to repeat a function called from a modeless odcl dialogue:

;;On click event for an (asynchronous) GraphicButton
(defun c:MyProject_AModelessForm_GraphicButtonAlert_OnClicked ( / )
  (dcl_SendString "TEST\n")
)

(defun c:TEST ()
  (alert "This is a test")
)
Title: Re: Enter to repeat command from a Dialog Menu.
Post by: owenwengerd on January 14, 2010, 08:11:32 AM
Quote from: Kerry Brown on January 13, 2010, 11:22:50 PM
the Event name in the Editor can be a function and the Event name in the Code remains a Command. ??

Yes, except that the "event name in the editor" should be called simply the "event name" and nothing more.