LabWindows/CVI Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
K_Joy

Add the functionality to "Add Event Case" to existing control callbacks

Status: New

I want to be able to do the following:

 

  1. Right-click on a control on my user interface and select “Add Event Case to Control Callback” (if a callback function already exists)
  2. CVI brings up a dialog similar to what you see at Code>>Preferences>>Default Events to select an event for that control
  3. Check the box for one or more events for that control, click OK, then
  4. Have CVI find the existing control callback function and add a case to the switch statement for each event I checked

If you haven’t written any code in the callback already, you can just change the default events and re-generate (replace) the control callback.

 

However, if you have already written code for one event case, the only way I can find to add an event case is to do it manually. I go to Code>>Preferences>>Default Events or use the Operate tool to look for the constant name of the event that I am interested in, then I go back to my code and manually type out “case EVENT_CONSTANT_NAME: break;” with the name of the event and hope I remember it correctly and spell it right.

 

CVI is all about minimizing user errors and reducing development time by, you know, not making you type things out yourself, so I think this functionality would be a useful addition.

3 Comments
tstanley
Active Participant
Not to shoot down an excellent idea, but for the current versions of CVI, if you are in an existing callback function you can right click on any of the EVENT macros and choose "Go to Definition" which will take you to the list of all the possible events which are defined in userint.h. There are also some helpful comments that describe what the eventData parameters are doing for the events that use them. This seems like it would be easier than using Default Events window or the operate tool.
K_Joy
Member

Thanks tstanley, I didn't know that! From there I can copy and paste the event I'm interested in back into a new case in the switch statement in my callback function, so that definitely makes it easier (and less error-prone).

I still think it would be nice if there were a way to select from available events for a control and have CVI automatically add event cases to the existing callback function for that control. 

RobertoBozzolo
Proven Zealot

That's what I was thinking of: default cases can be useful for massige code generation, like when you design a whole panel with its controls and associated callbacks and generate all the code in a single pass.

 

When you edit a single control, a new function "Edit events for the control" could be added to the context menu, with the ability to add new events or delete existing ones. The function should be tailored to the selectd control type, showing only applicable events more or less like the default cases panel (in fact it could be a customized instance of that panel, blocked to the appropriate control type and with the tree on the left hidden or disabled).



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?