LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Nugget of the week: Dynamic event registration

Apologies for dredging up an old thread.

 

Does anyone have experience doing this kind of stuff in an XControl?  The on and off nature of the Facade VI is making things difficult for me.

 

I have a picture control in the XControl that I click and drag on.  Obviously, what I'm trying to do is ignore the Mouse Move events unless I have clicked on the correct part of the image.

 

In Init I call an event I made called Init Events, where I register for the Mouse Move and set the others to a blank picture reference.  This doesn't work.  Mouse Move always triggers.  I've attached a very simple (relative to my real one) XControl to illustrate.

 

Any ideas?

 

Re the attached.

Test.vi is a vi that just has the xcontrol on it.  If you put breakpoints in the facade vi you can see it's not working how I want.

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 61 of 77
(2,894 Views)

@elset191 wrote:

Does anyone have experience doing this kind of stuff in an XControl?  The on and off nature of the Facade VI is making things difficult for me.


Déjà vu?

0 Kudos
Message 62 of 77
(2,884 Views)

 


@JackDunaway wrote:

@elset191 wrote:

Does anyone have experience doing this kind of stuff in an XControl?  The on and off nature of the Facade VI is making things difficult for me.


 

Déjà vu?


I don't think so...Though I have been wrong before.  Before I just wanted to act on the dynamic event.  Now I want to unregister and filter out the registered events.  I don't see how this can be done by using an extra reference in this case. 

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 63 of 77
(2,878 Views)

After sleeping on it, I was able to come up with a solution.  I created an event handler VI (much like Ben's example on the second page).

There were a few considerations to take into account because it is an XControl.  In my Facade VI when I call the Event handler, I had to call it dynamically so it wouldn't lock up the facade VI.  Also, I had to create a stop event that I fire in the Uninit Ability in order to stop the event handler subvi.

--
Tim Elsey
Certified LabVIEW Architect
Message 64 of 77
(2,841 Views)

what is that bloc i cn't found it on my labview ??

 

 

0 Kudos
Message 65 of 77
(2,385 Views)

Looks like DrawPoint.vi to me, located in the Graphics->Picture Funcitons palette.

0 Kudos
Message 66 of 77
(2,371 Views)

Great example - thank you!

 

I just started using dynamic events.

 

In the example:   I know how to create the Ref Constant for Picture (green color).  But how does one create the Static ref for Picture (blue color)?

 

Thanks again for the excellent example - cannot find much like this on NI site.

0 Kudos
Message 67 of 77
(2,126 Views)

Right click on the green one and select create constant.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 68 of 77
(2,115 Views)

Yet another necro for this great nugget.

I first read it years ago and I keep using it - great info. Let's see if I can give kudos a second time.

 

Today I wondered whether there is a way to tell what ref is registered to an event if you use DER to turn events on and off.

That would be a nice way to check whether the event is currently on or off.

Sure there are other ways to keep track of which events are currently on and off, but sometimes checking if an event was registered for an empty ref would be the most direct way.

 

Here is what I tried so far:

re-reading this thread 😉

setting "register for events" to read (found no option to do that),

wiring the reference created by "register for events" into a property node (broken wire),

wiring the reference created by "register for events" into a methode node (broken wire),

type cast is possible - but what to cast to?

 

Does anyone know a way to get the registered references out of the "register for events"-reference?

 

Best regards

Florian

 

Edit: Giving kudos to the original post again worked!

0 Kudos
Message 69 of 77
(1,963 Views)

You can use a cluster to hold all the Event Refnums - see this post:

http://forums.ni.com/t5/LabVIEW/Nugget-of-the-week-Dynamic-event-registration/m-p/1170399#M509947

If you make a Typedef for the cluster, you can give them nice names.

0 Kudos
Message 70 of 77
(1,914 Views)