Localising command line functions

Started by dan113, October 23, 2017, 06:39:40 AM

Previous topic - Next topic

dan113

I am trying to localise the event commands so when i start to type the opendcl event commands do not show. I have however been unable to achieve this can anyone help?

roy_043

If your dialog is modal then localization is indeed the answer. You can nest all event-handler functions and declare them as local variables in the main function.

For a modeless dialog you will have to rename the event-handlers. It is possible to enter names without the 'C:' prefix in the 'AutoLISP Function to Call On Event' field.

I am not sure why the default names have this 'C:' prefix.

dan113

I have tried localising them by nesting them also I have tried removing the c:. Localising has no effect and removing the c: just stops the event from firing. All that happens when localised is the commands on the command line return a not recognised error if activated.

roy_043

Here are some test files.

I did find something unexpected (note: I use BricsCAD):
Nested functions with the 'C:' prefix are added to the 'AUTOCOMPLETE' list of command suggestions when their parent function is called, even though they don't exist outside that context because their names are localized.

If the same is true for AutoCAD then the only solution is to always use names without the 'C:' prefix.

Maybe Owen can explain the reason for this 'C:' prefix for event-handlers.

dan113

Thats exactly what is happening, the autocomplete list is full of dcl event functions  ;D

I have tried without success to remove the c: I will keep trying....

roy_043

Quote from: dan113 on October 25, 2017, 02:40:21 AM
I have tried without success to remove the c: I will keep trying....
The example files demonstrate that as well. See the HideFuncTest/FormModeless/TextButton1#OnClicked function.

dan113

Quote from: roy_043 on October 25, 2017, 06:48:49 AM
Quote from: dan113 on October 25, 2017, 02:40:21 AM
I have tried without success to remove the c: I will keep trying....
The example files demonstrate that as well. See the HideFuncTest/FormModeless/TextButton1#OnClicked function.

I have tried further and even the example you kindly added does not work for me  :-\

I have loaded the files and the modal works but the autocomplete still shows the command and the modeless button doesn't work at all.

roy_043

I don't know why my modeless example does not work for you. Maybe somebody else (with an AutoCAD license) can jump in.

Fred Tomke

Hi, I always used more readable commands in control events, when the control's property EventInvoke was set to AllowCommand. Events are only hidden in commandline when EventInvoke was set to KeepFocus.

What I also did was to keep EventInvoke set to KeepFocus and call another command asynchronously within this event.
For example for a listview

(defun c:myproject/myfom/mylistview#OnDblClicked (intRow intCol)
  (dcl-SendString "MyCommandWhenListviewItemWasDblClicked\r\n")
); c:myproject/myfom/mylistview#OnDblClicked


I've just seen that I've let the event names unchanged as OpenDCL Studio has inserted them, but I added ^C^C in front of eventnames when I wanted to call a command within the event function. What I wanted to say: play with ^C^C.

Hope that helps,
Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

roy_043

@Fred:
I believe you have misunderstood the problem.
The OP wants to avoid including the names of event handler functions in the 'autocomplete' list. I have suggested two methods. The first method does not work (Modal example). The second (Modeless) example works on BricsCAD but apparently not on AutoCAD.

Why does the second example not work on AutoCAD?
And why do the default names of event handlers have the 'C:' prefix?

owenwengerd

Quote from: roy_043 on November 02, 2017, 03:57:56 PM
And why do the default names of event handlers have the 'C:' prefix?

I remember asking the same question when I started working on OpenDCL, but I don't remember why I couldn't change it. I'm pretty sure there is some Acad quirk (at least there was at one time) related to the C: prefix.
Owen Wengerd (Outside The Box) / ManuSoft

roy_043

So (to summarize):

How to Hide Event Handlers

Q:
How to stop event handler names from appearing in the AutoComplete list that pops up when the user starts typing a command?
A (BricsCAD):
You can remove the 'C:' prefix from the default event handler name. You will of course have to do this for both the .odcl and the .lsp file.
A (AutoCAD):
This is not possible because the 'C:' prefix cannot be removed. But it is possible to rename the function so the user is unlikely to see it. For example by replacing 'C:' with 'C:*'.

Q:
How to stop event handler calls from appearing in the command history?
A:
This issue does not apply to Modal forms. To hide these calls for a Modeless form the EventInvoke property of the form should be set to Synchronous. This does mean you can no longer call commands from event handlers. To use commands you will then have to use a dcl-SendString solution as demonstrated by Fred Tomke's code:
(defun c:myproject/myfom/mylistview#OnDblClicked (intRow intCol)
  (dcl-SendString "MyCommandWhenListviewItemWasDblClicked\r\n")
)