11-30-2010 01:21 AM
The CVI2009 SP1 OperateSplitter( ) online help says:
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?
Solved! Go to Solution.
11-30-2010 04:03 AM - edited 11-30-2010 04:04 AM
@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
11-30-2010 04:19 AM
@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.
11-30-2010 11:49 AM
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