Enter button functionality

Started by Emiliano · 2016-07-21 07:37 UTC · 8 replies · SMF topic #2389

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?
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
author=Fred Tomke link=topic=2389.msg11964#msg11964 date=1469088707 wrote:
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?
Hi, Emiliano,

I 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.

"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
author=Fred Tomke link=topic=2389.msg11966#msg11966 date=1469096123 wrote:
"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
author=Fred Tomke link=topic=2389.msg11966#msg11966 date=1469096123 wrote:
Hi, Emiliano,

I 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.

"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
author=velasquez link=topic=2389.msg11968#msg11968 date=1469188506 wrote:
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:

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

(defun c:MyFunctionName (/ )
  (princ "\nTEST")
)
author=Emiliano link=topic=2389.msg11969#msg11969 date=1469189228 wrote:
[quote author=velasquez link=topic=2389.msg11968#msg11968 date=1469188506]
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:

(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
author=Emiliano link=topic=2389.msg11967#msg11967 date=1469105600 wrote:
[quote author=Fred Tomke link=topic=2389.msg11966#msg11966 date=1469096123]
"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?