auto generate event functions

Started by Jim Short, February 22, 2018, 08:18:02 AM

Previous topic - Next topic

Jim Short

When one was several text boxes on a form, many event calls are possible to provide detailed control of what user sees, and how user interacts with them.
This requires lisp to provide many similar event defuns. I have been looking at to write one master function to handle the same event for four boxes. The followings does not work but gives the idea:
;;;(setq
;;;      zones
;;;      '("FeedZone""StartZone""RoughZone""FinishZone")
;;;   )
;;;   (foreach z zones
;;;      (defun-q-list-set
;;;         (read (strcat "c:uMill/WorkZones/tb" z "#OnSetFocus"))
;;;         '(
;;;            ()
;;;            (dcl-TextBox-SetSel
;;;               (read (strcat "c:uMill/WorkZones/tb" z))
;;;               0
;;;               -1
;;;               t
;;;            )
;;;         )
;;;      )
;;;   )

Has anyone succeeded with something like this?

Thanks,
Jim
Jim Short

Fred Tomke

Hi, do all the event function do the same content or do you just want to set the events at runtime? I did this and it worked very well. For the case an event of many controls do the same I just set a single common event function to all the controls.
Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

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

Jim Short

Fred,
In my example, the zones list is used to generate the four control names for (dcl-TextBox-SetSel. This also could be done in a subroutine called with a cntrlName arg.
My real desire was to use the zones list to generate four event defuns at lisp load time of the type c:uMill/WorkZones/tb[CntrlName]#OnSetFocus.
Thus the use of read statement.
Do you have an example of your techniques?
Thanks,
Jim
Jim Short

Fred Tomke

Aaah, I begin to understand.
All you need to know is that you just need to address events like properties:

(dcl-Control-SetProperty project_dialog_control "MouseMove" "c:project_dialog_control_OnMouseMove")

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

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

Fred Tomke

.... and then you override c:project_dialog_control_OnMouseMove with the evaluation of your string...
Fred Tomke
Dipl.-Ing. (FH) Landespflege

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

Jim Short

Is this the same as changing the autolisp function to call on event, in OpenDCL Editor Event Tab?
Except that the function name that is automatically shown there, is being modified at runtime?
Does that allow several text boxes to call the same function by defining it in that field?
OR modify it as shown in your example at runtime.

It has been a long time since I thought about this. And it could be useful.




Jim Short

Fred Tomke

I already thought, that it might not be clear enough, unfortunately I've not the time for a sample these days.
With assigning events at runtime you have the chance to decide when and which event should get active or inactive (empty string) at runtime. And you can change an event function at runtime.
I mean several options:


  • fixed event name for a function always called at the event - you only have to redefine the function at runtime with another code
  • A single event function could be set to many controls/events using the same event arguments
  • leave the event name empty in studio and just set it when needed. The name of the event function may depend on the current needs of the user
  • you can turn off events at runtime

But be careful: the number of arguments of the event function have to match to the underlying event (see Button_OnMouseMove vs. Button_OnClicked)!

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

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