Enter button functionality

Started by Emiliano, July 21, 2016, 12:37:14 AM

Previous topic - Next topic

Emiliano

Hi,
usually in AutoCAD / BricsCAD, pressing Enter may be started the last used command.

I created a ControlBar with buttons linked to a function c:xxxxxx (), unfortunately when I use these functions the Enter key does not start the last command c:xxxxxx ().

Is it possible do this?

Fred Tomke

Hi, Emiliano, sure it is. I made it this way:


  • OpenDCL Studio Project > Button > Property Pane > Event Invoke = KeepFocus
  • OpenDCL Studio Project > Button > Events Pane > OnClicked event > ^C^Cc:project_form_button_OnClicked
  • In the code of c:project_form_button_OnClicked I check some prerequisites and then I call the "reading-friendly" command (dcl-sendstring "MyCommand\r")

You can also set EventInvoke to AllowCommand and set the "reading-friendly" command to the event name of the control.

Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

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

Emiliano

Quote from: Fred Tomke on July 21, 2016, 01:11:47 AM
Hi, Emiliano, sure it is. I made it this way:


  • OpenDCL Studio Project > Button > Property Pane > Event Invoke = KeepFocus
  • OpenDCL Studio Project > Button > Events Pane > OnClicked event > ^C^Cc:project_form_button_OnClicked
  • In the code of c:project_form_button_OnClicked I check some prerequisites and then I call the "reading-friendly" command (dcl-sendstring "MyCommand\r")

You can also set EventInvoke to AllowCommand and set the "reading-friendly" command to the event name of the control.

Regards, Fred

I'm not sure I understand:
in OpenDCL Studio Project > Button > Property Pane > Event Invoke = KeepFocus I have only "asynchronous" e "synchronous" :-(
In code c:project_form_button_OnClicked where I have to write  (dcl-sendstring "MyCommand\r") ?? "MyCommand"must be replaced with the name of my function?

Can you send me a sample project?

Fred Tomke

Hi, Emiliano,

QuoteI have only "asynchronous" e "synchronous"
You're right. In the German release there are the old values: Keep focus means synchronous and Allow command means asynchronous.

Quote"MyCommand"must be replaced with the name of my function?
"MyCommand" is a synonym for your desired command to be executed. I don't want to see the event handler names in the command history, especially those ones with additional arguments like ListView_OnClicked. Thats why, at first I call a internally defined function synchronously (c:project_form_button_OnClicked) and within its code I call a command asynchronously. The command is that one, which can be repeated by pressing enter.

Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

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

Emiliano

Quote from: Fred Tomke on July 21, 2016, 03:15:23 AM
"MyCommand" is a synonym for your desired command to be executed. I don't want to see the event handler names in the command history, especially those ones with additional arguments like ListView_OnClicked. Thats why, at first I call a internally defined function synchronously (c:project_form_button_OnClicked) and within its code I call a command asynchronously. The command is that one, which can be repeated by pressing enter.

Regards, Fred

Hi Fred
Now I understand!
Your solution works properly!
Too bad I have a few dozen buttons to correct  :'(

Thanks for your help

velasquez

Quote from: Fred Tomke on July 21, 2016, 03:15:23 AM
Hi, Emiliano,

QuoteI have only "asynchronous" e "synchronous"
You're right. In the German release there are the old values: Keep focus means synchronous and Allow command means asynchronous.

Quote"MyCommand"must be replaced with the name of my function?
"MyCommand" is a synonym for your desired command to be executed. I don't want to see the event handler names in the command history, especially those ones with additional arguments like ListView_OnClicked. Thats why, at first I call a internally defined function synchronously (c:project_form_button_OnClicked) and within its code I call a command asynchronously. The command is that one, which can be repeated by pressing enter.

Regards, Fred

Hello Fred,
Do you have an example of how this works in the command history?
I did not quite understand my language does not help.
Regard, Velasquez

Emiliano

Quote from: velasquez on July 22, 2016, 04:55:06 AM
Hello Fred,
Do you have an example of how this works in the command history?
I did not quite understand my language does not help.
Regard, Velasquez

I hope this helps you:
Code (autolisp) Select

(defun c:Nome_MainForm_ButtonName_OnClicked (/ )
  (dcl-sendstring "MyFunctionName\r")
)

(defun c:MyFunctionName (/ )
   (princ "\nTEST")
)

velasquez

Quote from: Emiliano on July 22, 2016, 05:07:08 AM
Quote from: velasquez on July 22, 2016, 04:55:06 AM
Hello Fred,
Do you have an example of how this works in the command history?
I did not quite understand my language does not help.
Regard, Velasquez

I hope this helps you:
Code (autolisp) Select

(defun c:Nome_MainForm_ButtonName_OnClicked (/ )
  (dcl-sendstring "MyFunctionName\r")
)

(defun c:MyFunctionName (/ )
   (princ "\nTEST")
)


thank you
I will test in my project.
Regards, Velasquez

Emiliano

Quote from: Emiliano on July 21, 2016, 05:53:20 AM
Quote from: Fred Tomke on July 21, 2016, 03:15:23 AM
"MyCommand" is a synonym for your desired command to be executed. I don't want to see the event handler names in the command history, especially those ones with additional arguments like ListView_OnClicked. Thats why, at first I call a internally defined function synchronously (c:project_form_button_OnClicked) and within its code I call a command asynchronously. The command is that one, which can be repeated by pressing enter.

Regards, Fred

Hi Fred
Now I understand!
Your solution works properly!
Too bad I have a few dozen buttons to correct  :'(

Thanks for your help

Hi Fred,
I noticed a small problem born after implementing this.
In my ControlBar it is active the event 'MouseEntered'.
The "Event Invoke" was "asynchronous" so, while it was active a related function to a button of ControlBar if I passage over the ControlBar displays the message "Unable to return to LISP".

So I have tried to set Event Invoke = synchronous, so the problem is solved, but I want to prevent the MouseEntered event's operation when there is an active command.
To do this I checked the variable (if (= (getvar "CMDNAMES") "").....
I want to prevent the event activation 'MouseEntered' even during the execution of a LISP function.
How can I do?