Author Topic: Localising command line functions  (Read 236 times)

dan113

  • Member
  • *
  • Posts: 4
Localising command line functions
« on: October 23, 2017, 06:39:40 AM »
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

  • Sr. Member
  • ****
  • Posts: 326
Re: Localising command line functions
« Reply #1 on: October 24, 2017, 03:27:25 AM »
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

  • Member
  • *
  • Posts: 4
Re: Localising command line functions
« Reply #2 on: October 24, 2017, 01:18:02 PM »
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

  • Sr. Member
  • ****
  • Posts: 326
Re: Localising command line functions
« Reply #3 on: October 25, 2017, 02:29:05 AM »
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

  • Member
  • *
  • Posts: 4
Re: Localising command line functions
« Reply #4 on: October 25, 2017, 02:40:21 AM »
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

  • Sr. Member
  • ****
  • Posts: 326
Re: Localising command line functions
« Reply #5 on: October 25, 2017, 06:48:49 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

  • Member
  • *
  • Posts: 4
Re: Localising command line functions
« Reply #6 on: October 31, 2017, 01:22:28 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

  • Sr. Member
  • ****
  • Posts: 326
Re: Localising command line functions
« Reply #7 on: October 31, 2017, 08:41:40 AM »
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

  • OpenDCL Technician
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1996
  • [ Mr. Bad Guy ]
    • Kommunale Entwicklungsplanung auf digitaler Basis - digital landscape and urban design
Re: Localising command line functions
« Reply #8 on: November 02, 2017, 01:44:33 PM »
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

Code: [Select]
(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

  • Sr. Member
  • ****
  • Posts: 326
Re: Localising command line functions
« Reply #9 on: November 02, 2017, 03:57:56 PM »
@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

  • Administrator
  • Hero Member
  • *****
  • Posts: 2909
    • Outside The Box
Re: Localising command line functions
« Reply #10 on: November 03, 2017, 07:09:48 AM »
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.

roy_043

  • Sr. Member
  • ****
  • Posts: 326
Re: Localising command line functions
« Reply #11 on: November 04, 2017, 03:16:06 AM »
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:
Code: [Select]
(defun c:myproject/myfom/mylistview#OnDblClicked (intRow intCol)
  (dcl-SendString "MyCommandWhenListviewItemWasDblClicked\r\n")
)