Jump to content

Dynamically registered events in XControls


JDave

Recommended Posts

Well, I just started peeking into the world of XControls and it does look fun. However, when I tried to use a dynamically registered event -- it just don't work. Has anyone had success with this, or will I just need to restrict my events to static events (since User Events don't work either) ?

David

Link to post

QUOTE(JDave @ Nov 29 2007, 06:44 PM)

I am using user events, you can see them in my Boolean XControl. Where I create the event registration in the Init ability and destroy them in the Uninit event.

I fire events from methods and properties without problems and my facade VI gets triggered by them.

However in my latest experience I have issues where I fire them from a callback VI, this doesn't trigger the facade VI.

So it shouldn't give you any problems unless you get really fancy.

Ton

Link to post

QUOTE(tcplomp @ Nov 29 2007, 10:49 AM)

Thanks for the clarification Ton. I misunderstood the problem you were having with the callback VIs.

Any experience using other dynamic events? (non User-Events)

Link to post

QUOTE(JDave @ Nov 29 2007, 07:53 PM)

Thanks for the clarification Ton. I misunderstood the problem you were having with the callback VIs.

Any experience using other dynamic events? (non User-Events)

No, I've used them in the start-up fase of the Boolean XControl and seen no issues.

Ton

Link to post

QUOTE(tcplomp @ Nov 29 2007, 06:49 PM)

Presumably, running a property or method vi 'wakes up' the facade of the XControl because it is likely that some aspect of the appearance will need updating, in which case the facade can catch your user event. Since the XControl doesn't know that the callback vi might want to mess with the facade, it doesn't get woken up. I guess if your callback vi could get a reference to the XControl you could call some random (dummy) property or method after you send the user event to manually 'awaken' the XControl facade...

Link to post

I have succesfully edited your XControl to react on dynamic events.

I took multiple steps and don't know exactly what is neccesary, but I think it is this:

  • Create space in you state for a Event Registration Refnum (ERR), make sure it is of the correct type
  • In the init VI set some messaging up that let the Facade VI know it needs to initialized
  • In the init routine of the facade VI, put the multicolumn listbox in the ERR
  • Don't forget to destroy the ERR in the uninit VI

In order to get this to work I had to remove the example VI from the XControl (why did you add the example to the XControl?)

Here's the core code:

post-2399-1196710064.png?width=400

Download File:post-2399-1196710162.zip

Ton

Link to post

QUOTE(tcplomp @ Dec 3 2007, 11:28 AM)

In order to get this to work I had to remove the example VI from the XControl (why did you add the example to the XControl?)

Because I'm a newbie ;) at XControls.

Thanks for fixing that. I will give it a good study.

David

Link to post

QUOTE(JDave @ Dec 3 2007, 08:34 PM)

Because I'm a newbie ;) at XControls.

Thanks for fixing that. I will give it a good study.

David

Your question, made me rethink my .Net Problem and I have succesfully solved it.

Ton :thumbup:

Link to post

QUOTE(tcplomp @ Dec 3 2007, 11:52 AM)

Your question, made me rethink my .Net Problem and I have succesfully solved it.

That's good to hear.

Another one question -

Has anyone ever registered for events from the containing VI? I want to capture when the Escape Key is pressed, but the XControl doesn't always have focus (so I can't capture it at the XControl level). I haven't been able to successfully register for any events at the VI level.

In fact, when I registered for Key Down? on the owning VI in the Exec State Change event (idle->running), it locks the entire UI.

Link to post

QUOTE(JDave @ Dec 5 2007, 05:01 PM)

Has anyone ever registered for events from the containing VI? I want to capture when the Escape Key is pressed, but the XControl doesn't always have focus (so I can't capture it at the XControl level). I haven't been able to successfully register for any events at the VI level.

I figured out how to do this. I believe it requires the use of a separate daemon VI to monitor the events. At least it works. When I get some more stuff worked out I will post the code.

David

Link to post
  • 2 weeks later...

QUOTE(phuzionz @ Dec 19 2007, 10:03 AM)

Are you sure that the VI is working, when i press the escape button, labview is crashing!

Br,

Jeroen

Here's a tested version on LabVIEW 8.0.(1?) that works.

Only the dynamic key-down doesn't work.

However the dynamic mouse-down works.

Ton

Link to post
  • 3 weeks later...

QUOTE(DaveKielpinski @ Jan 5 2008, 02:44 PM)

Hi Ton,

I've run into a similar problem and am having a hard time with it. Could you post about your solution?

Thanks,

Dave

Here's a zip that solves this.

Be aware it's not fail save and not yet finished.

Ton

Link to post

QUOTE(tcplomp @ Jan 6 2008, 01:16 AM)

Here's a zip that solves this.

Be aware it's not fail save and not yet finished.

Ton

Thanks for that. It is quite clear. It seems like you work around the basic problem (external User Events don't trigger an XControl) by having the shell VI change the Val(Sgnl) property of the XControl. Then the "Data Change" event fires and the User Events are processed normally.

For my application this means that the shell VI is a simple event handler that duplicates some of the XControl functionality. In terms of the self-similar XControl hierarchy I posted about (http://forums.lavag.org/XControl-hierarchy-for-event-handling-t9793.html), this means each node in the tree has to have a daemon VI to wake it up when it gets a message from a descendent.

Does anyone know whether the basic problem will be addressed in a new LV version? It seems kind of silly to have some User Events fire in XControls and others not, but maybe there is an underlying reason...

Link to post
  • 5 years later...
QUOTE(JDave @ Nov 29 2007, 06:44 PM)

I am using user events, you can see them in my Boolean XControl. Where I create the event registration in the Init ability and destroy them in the Uninit event.

I fire events from methods and properties without problems and my facade VI gets triggered by them.

However in my latest experience I have issues where I fire them from a callback VI, this doesn't trigger the facade VI.

So it shouldn't give you any problems unless you get really fancy.

Ton

I know the topic is a little old but I found something strange (but positive)  with the registering callback node.(LabVIEW 2012)

 

I wanted to create a way to monitor the lost focus event. This event is not native in LabVIEW. So I tried to register a callback to react to a pane: mouse down event. When this event is triggered I check which control has focus and execute some code. 

 

In .vi form it doesn't work but as an executable it works great. I attached a simple code. Have  a look to the init ability. Tried the unitTest.vi then the UnitTest.exe. 

 

Romain

Xcontrol with focus lost event.zip

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.