Enter to repeat command from a Dialog Menu.

Started by Kerry, January 13, 2010, 04:27:23 PM

Previous topic - Next topic

Kerry


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
Perfection is not optional.
My other home is TheSwamp

BazzaCAD

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 . :)
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

Kerry

#2
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 :) )
Perfection is not optional.
My other home is TheSwamp

owenwengerd

Remove the C: from the OnClicked event handler name so it runs as a command instead of a function.

Kerry



Owen,
Sorry, I don't quite get your meaning ??
Perfection is not optional.
My other home is TheSwamp

Kerry


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 !!
Perfection is not optional.
My other home is TheSwamp

owenwengerd

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.

Kerry


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.


Perfection is not optional.
My other home is TheSwamp

owenwengerd

You don't need the (defun KDUB_...) as it's not called.

Kerry


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
Perfection is not optional.
My other home is TheSwamp

BazzaCAD

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)
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

owenwengerd

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?

Kerry

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
Perfection is not optional.
My other home is TheSwamp

Kerry

#13
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.
Perfection is not optional.
My other home is TheSwamp

Danner

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")
)