10-31-2008 08:37 AM
Dear all,
There are about 4-5 events associated with the Graph in my application.
Is there a way that all those events would register at the time the mouse enters the Graph and Unregister those events when Mouse leaves the Graph?
I think the registration would be done inside the Event Structure on "Mouse Enter" event, but have no clue how to do it .
Thanks,
Ritesh
10-31-2008 09:57 AM
10-31-2008 10:33 AM
You are on the right track.
Also see this
11-03-2008 01:46 AM
Hi,
That nugget was really of great Help!
However, i would like to know if 2 or more different dynamic events can be registered to one event Structure.
I am attaching one example, where i am displaying the coordinates of the cursor if the Left Click is pressed and moved. I am using 2 different Event Strucutures for different Graphs.
Can events for both the Graphs be registered to one event structure ?
Thanks,
Ritesh
11-03-2008 03:18 AM
11-03-2008 03:40 AM
I would not use dynamic events for such a simple task. It adds way to much extra complexity without any real benefit.
Just keep the mouse state (button up or down on any of the two graphs) in a shift register and use plain old static events.
Here's a quick rewrite to show the idea.
11-03-2008 03:17 PM
Actually that is not the actual application that i am working on. That was just a simple example i tried to know how dynamic event structure works.
My real application is far more complex.
1) On Mouse Down, it will select the plot on which the mouse was clicked.
2) On mouse Move, it will move the plot Up or Down(as the mouse is moved over the graph)
The thing that adds spice to the complex program are the markers.
There are markers on each plot.
So every time there is a Mouse Down event, i need to check if there's any Cursor that has been grabbed. If yes, i deslect the plot and move the cursor else Mouse move event takes place .
i found Dynamic Event Registration(DER) to be far more easier to implement for such a complex program.
Could you please enlighten me on What kind of Complexities are associated with Dyanamic Event registration??
I literally dont know if using DER or the shift register is efficient for my application. So knowledge on Complexities associated with DER would really help to make my Application more Robust.
Thanks,
Ritesh
11-03-2008 04:47 PM
Well I don't like contradicting Altenbach, in fact it's usually him correcting me, but I think dynamic registration is a good thing to use.
"Normal" events are only triggered once. By "Normal" I mean the events offered in an event case without any dynamic registration. Thus if there are two pieces of code waiting for the event via a "normal" Event case, only one will actually see an event, correct? (This is a good chance to correct me if I'm wrong)
By switching over to dynamic registered events you can have three or four pieces of code acting on the events without a problem (logical problems / race conditions aside) because each registration causes an extra "instance"(?) of the event to be fired, and all waiting event structures see the events.
I'^m currently working on a project where I'm extending the functionality of a control using a component which makes widespread use of dynamic registration for specific controls. I can just drop the code on my block diagram without having to worry if there's an event structure somewhere else waiting for the same event.
I have grown to be very fond of dynamic event registration (And user events).
Shane.
11-03-2008 05:03 PM
Intaris wrote:Well I don't like contradicting Altenbach, in fact it's usually him correcting me, but I think dynamic registration is a good thing to use.
Shane
Yes, if the complexity of the problem requires it. In the simple demo above, it just adds more code. My head gets dizzy if I constanty shuffle dynamic events around. I don't know what's more efficient, (1) swapping dynamic events around or (2) spinning an empty event case once in a while (my code).
Intaris wrote:"Normal" events are only triggered once. By "Normal" I mean the events offered in an event case without any dynamic registration. Thus if there are two pieces of code waiting for the event via a "normal" Event case, only one will actually see an event, correct? (This is a good chance to correct me if I'm wrong)
I don't quite understand what you mean here. If two event structures are waiting for the same event, both will fire if the event occurs. Have a look at this old example. Both event structures see the stop event.
11-03-2008 06:29 PM
Altenbach.
Yes, you are correct of course. I should have known you'd correct me on something. For some reason I had the notion in my head that certain circumstances could lead to problems with multiple event structures set to handle the same event.....
Kind of negates my previous love-song for dynamic event registration a bit doesn't it.....
Normal balance of power restored. I keep learning.....
Shane.