LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

OperateSplitter doesn't execute the control callback

Solved!
Go to solution

The CVI2009 SP1 OperateSplitter( ) online help says:

  • Use this function to mimic the movement of a splitter control by the interactive user.

Unfortunately this is not completely true:

if the splitter has a control callback, this callback is executed when the splitter is moved with a mouse drag, but is not executed when the splitter is moved by OperateSplitter( )

It's easy to see this running the supplied \CVI2009\samples\userint\events.cws example, adding

 

OperateSplitter(panel, PANEL_SPLITTER, width - gPanelWidth);

at line 159 of events.c

When you resize the panel you can see that the callback of PANEL_SPLITTER is not called.

When you move the same splitter with the mouse, the callback is called.

 

Is this an expected behaviour?

 

 

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 1 of 4
(3,219 Views)

@vix wrote:

if the splitter has a control callback, this callback is executed when the splitter is moved with a mouse drag, but is not executed when the splitter is moved by OperateSplitter( )


Is this not just the standard CVI callback behaviour? If you have a callback on a numeric control, you would not expect it to be called just because a SetCtrlVal() issued somewhere in a program altered the control's value.

 

JR

0 Kudos
Message 2 of 4
(3,210 Views)

 


@jr_2005 wrote:
Is this not just the standard CVI callback behaviour?

 

I don't think so, because I can change the splitter position changing its attributes ATTR_LEFT and ATTR_TOP with SetCtrlAttribute() and in this situation the callback mustn't be called (like SetCtrlVal for a numeric control).

But if I use OperateSplitter() which "mimic the movement of a splitter control by the interactive user" (from CVI help) I think the callback should be called, because this is the behavior when the user drags the splitter, and this function emulates this user action.

 

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 3 of 4
(3,206 Views)
Solution
Accepted by topic author vix

As has been pointed out, events generally aren't sent as a result of a programmatic action. The callback and events are there to let the programmer react to *user* actions. When the programmer initiates the action, you don't need an event letting you know that the action took place, since you initiated it.

 

In this case, you could do whatever the callback does after calling OperateSplitter (or even call the callback yourself).

 

OperateSplitter exists so that any controls attached to the splitter will be sized or moved as if the user operated the splitter, as opposed to just changing the position of the splitter (which is what SetCtrlAttribute with ATTR_LEFT or ATTR_TOP would do).

 

Hope this helps,

 

- jared

0 Kudos
Message 4 of 4
(3,183 Views)