From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Triggering an event on a picture created with LV Scripting

Hi,

 

I have a VI that is creating a scripted VI with a couple of pictures in it, opens the front panel and executes the scripted VI. Now I want to trigger an event by clicking on one of the pictures. I thought I might be able to do that using the mouse modifiers property node, but it looks like the VI does not react on events on the scripted VI's front panel.

 

If anyone had any idea on how to proceed I would really appreciate it.

0 Kudos
Message 1 of 13
(4,019 Views)

duplicate post, answered here : http://forums.ni.com/t5/LabVIEW/Triggering-an-event-on-a-picture-created-with-LV-Scripting/m-p/21335...


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 2 of 13
(4,015 Views)

If you want an event triggered by clicking on a picture in the scripted VI, you will need to script an event structure into the VI to capture the mouse event and send that event to wherever you wish to process it.  This is complicated by the fact that the event structure is not very scripting friendly.  You have a couple of choices:

 

  1. Create a template which contains your picture, the event structure and prepopulated event case.  Move this from your template to your scripted VI.
  2. Create a template which contains an event structure and user event for the picture mouse event.  Move as before.

Item 1 is probably easier.  You can send the event to your original VI using user events, queue, etc.

0 Kudos
Message 3 of 13
(4,014 Views)

This should contain all the interesting parts...

0 Kudos
Message 4 of 13
(4,007 Views)
I don't think that your suggestion is viable, because the picture in the scripted VI is only being created while executing the VI, therefore I cannot create a template containing it, can I? And because all I have of the picture is a reference, I cannot use an event structure either. Please correct me if I'm wrong... 

 

 


DFGray wrote:

 

If you want an event triggered by clicking on a picture in the scripted VI, you will need to script an event structure into the VI to capture the mouse event and send that event to wherever you wish to process it.  This is complicated by the fact that the event structure is not very scripting friendly.  You have a couple of choices:

 

  1. Create a template which contains your picture, the event structure and prepopulated event case.  Move this from your template to your scripted VI.
  2. Create a template which contains an event structure and user event for the picture mouse event.  Move as before.

Item 1 is probably easier.  You can send the event to your original VI using user events, queue, etc.


 

0 Kudos
Message 5 of 13
(4,005 Views)

You cannot create a front panel control while a VI is executing.  This would require compiling the VI while it is executing.  Normally, pictures are created in a picture control, which has a rich set of events available which can be dynamcially tailored to the contents of the picture (e.g. filter based on location).  All of this happens in the event structure in prewritten code.  One could also drop a picture as a decoration, and events on it would then be handled with panel or pane events filtered to the correct area.  Finally, one could use the picture as a background and again use panel or pane events filtered for area.

0 Kudos
Message 6 of 13
(4,002 Views)
I cannot create a front panel control in the same VI, but I can create a front panel control in another VI (the VI I am calling "scripted VI"), which is exactly what I am doing. But therein also lies the problem, because I cannot access an event on the front panel of the scripted VI from the calling VI, which I tried using a property node with mouse modifiers.button down. Could you please take a look at the VI I posted?
0 Kudos
Message 7 of 13
(3,999 Views)

I did use the template technique mentioned by DFGray, example posted here : http://lavag.org/topic/13499-utility-that-creates-vis-to-readwrite-a-section-cluster-fromto-ini-file...

I think you could use it too.

 

Hope this helps

 

ps : can't open your VI now, I'm installing LV 2012...


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 8 of 13
(3,996 Views)

Right, just took a look at you VI, indeed, I beleive your best option is to create a template VI with a picture control on the FP and a event structure on the BD, in that event structure create and event on the picture control (either value change or mouse down event) save that VI and in your scripter VI instead of creating a new vi from scratch you can create a copy of the other vi, run it and then fire the event on the picture control.

 

The link I gave above uses a similar technique, hope it makes sense to you.

 

As DFGray said you can't create and event structure and add events to it with scripting (well you can create an event structrue and create frames but then you can't edit them to define what event you want them to catch, it would be cool to be able to do that but I doubt it's a priority for NI to extend scripting that way.

 

Enjoy!


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 9 of 13
(3,989 Views)

I've just posted an idea for a more scripting friendly event structure : Vote here


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 10 of 13
(3,964 Views)