LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Using GetActiveControl for table.

I need to get the active control and the cell selected when I left click on a cell in a table. I have 3 table on the panel. When I click on the table for the first time and respond to the left_click callback the GetActiveControl does not return the ID of the table clicked on. It seems that GetActiveControl always returns the previously active control. I have also tried to use the mouse position to find the selected table using the mouse state functions without success.
0 Kudos
Message 1 of 4
(2,869 Views)
I suggest you modify your code to respond to the EVENT_GOT_FOCUS event; the 'control' parameter of the function is the ID of the control that fires the callback (i.e. the active control).


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?
0 Kudos
Message 2 of 4
(2,869 Views)
I reconsidered your problem and I can add a few details more.

1. I'm not sure of it, but I can imagine that GetActiveCtrl returns previous control ID because some events (among them mouse events) can be swallowed (discarded), so the GUI has not yet changed the 'active' control
2. For the same reason, if you wait until the GOT_FOCUS event, presumably GetActiveCtrl returns the correct contrl ID
3. In any case, the 'control' parameters contains the correct ID even in the left_click event

Hope all this helps you
Roberto


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?
0 Kudos
Message 3 of 4
(2,869 Views)
Hi,

This is actually expected behavior, when an event gets fired, the first function to be called is you callback; then the internal callback of the table control. The reason for this is so that you can swallow the event and trick the table on ignoring certain events. What I recommend to do here to set a deferred callback that will execute after the internal table callback gets executed.

Here is a very usefull link for this:
KnowledgeBase 322DCQ8O: Why Do I Read The Wrong Active Cell Value From a Table Control In The Callba...

It includes a link to an example on setting the deferrad callback.

I hope this helps.

Regards,

Juan Carlos
N.I.
Message 4 of 4
(2,869 Views)