01-30-2008 09:31 AM
01-30-2008 01:48 PM - edited 01-30-2008 01:49 PM
Hi Pierre,
To answer your direct question of "is there a way to order events", the answer to that is no. We don't state that events will always fire in a specific order because they don't and because of that, your code shouldn't rely on any specific order. I think its fine that you expressed your opinion of what you believe the order of events should be. Really the order of events is arbitrary and thus could be argued either way. When we first started CVI, we of course had just a few events but over time that number has greatly increased and so having a "specific" order really doesn't make sense, at least from our perspective.
If you are having a specific issue with regards to when events fire, please let me know and we can provide some suggestions to resolve your issue.
Just as a side note, the only type of documentation that we mention that is similar to this is the topic entitled Precedence of Callback Functions which describes the order of how events trigger callback functions.
Thanks for your thoughts.
Best Regards,
01-31-2008 03:52 AM
01-31-2008 01:16 PM
Hi Jolaf,
Let me first clarify what I meant by events not always firing in a specific
order as it can be a bit confusing. The order that events fire should be
consistent relative to an exact specific action but can change depending
upon what other actions are taking place at that time. So what does that
exactly mean?? Well, let’s say that you simply clicked on a button and you
received an EVENT_LEFT_CLICK, EVENT_COMMIT, EVENT_LOST_FOCUS and
EVENT_GOT_FOCUS in that order. Then I would expect if you did the exact same
action of simply clicking that button, you should receive those events in that
order. The order of those events could change if you had other actions taking
place that could affect these events.
Now with regards to my comments about event order being arbitrary, let’s take
the EVENT_LOST_FOCUS and EVENT_GOT_FOCUS example. It wouldn't make any
difference if we fired EVENT_LOST_FOCUS first and then EVENT_GOT_FOCUS or the
opposite of that. Because events are synchronous in our UI (i.e. our UI is
single-threaded), only 1 event will be sent to a callback function at a time
(i.e. 2 events can't be fired at the same). So this means that for
example, if the EVENT_LOST_FOCUS event fires first, then at a given time no
controls have focus because the EVENT_GOT_FOCUS event hasn't been
handled. If we swapped the order of these events with the got focus event
firing first, then at one point, we would have 2 controls with focus which is
really "illegal". So this is what I mean event order is arbitrary.
Now that we have cleared that up hopefully, as far as why you are seeing is a
crash with that specific order of events doesn't make a lot of sense to me
right now. Could you perhaps post some example code that I could look at
that to see how you are handling those events? Or if that's not possible, maybe
some pseudo-code on how you are handling the events right now (i.e. please be
specific with regards to which events you are working with; LEFT_CLICK,
GOT_FOCUS, etc). Having something to look at will help me figure out what
scenario you are in. I don't want to make too many assumptions since I'm not
clear on your exact setup.
Best Regards,
01-31-2008 04:07 PM
01-31-2008 04:38 PM
Hi Jolaf,
It seems as if you are wanting all of the events for button A for example to
fire and then all the events for button B to fire. CVI isn't designed in this
fashion and for good reason. For example, the easiest example I can give
is that we allow users to swallow events. This means that if for example,
you swallow the right-click event in the control callback, the control itself
will not be able to perform its default action upon receiving that event. At
that point, it’s as if the user had never clicked on the button.
We couldn't have this feature if we followed the pattern of executing all of
"button A's" events first and then button B's.
As far as documentation on these internal mechanisms, we have other 30 events
and we just can't document every single combination of actions and their corresponding
order of events.
Now as far as your specific scenario of utilizing/sharing resources based off
when events occur, this really isn't a common use-case we thought of and it’s
actually the first time we've heard of somebody doing this. Since you are
going to need to work with our current CVI design, I would suggest basing your
code always off the EVENT_GOT_FOCUS event and when that occurs to steal the
resource from "button A". You just can't depend upon
button A firing the EVENT_LOST_FOCUS event before button B's focus events
and commit events occurring.
Best Regards,