LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

background Picture area of screen works like a button

I want the area of the screen to be assigned to a button. When you click that area of the image it will push the button. 

 

 Capture.PNG pixel area that if you click inside it will create a Boolean True.

 

 

0 Kudos
Message 1 of 15
(3,132 Views)

You don't give sufficient information, but there are many possibilities.

 

  • That area of the background image could be a button customized with the picture part imported as flat picture (see here).
  • You could display the image in a picture indicator and handle the moused-down coordinates.
  • ...
0 Kudos
Message 2 of 15
(3,120 Views)

You have several requirements:

  • Set a Boolean value to True when an area of the Front Panel is "pressed" (or "sees" a Mouse Down).
  • Have the specific area be rectangular in shape, with sides parallel to the edges of the display.
  • Have the specific area be otherwise "invisible".

You do not say what happens if the Boolean value is already True -- this is something you might consider.  You also do not say anything about the timing of the Mouse Down action and the switching of the Boolean, another thing you might want to consider.

 

The most straight-forward way I can think to do this (which requires the minimal amount of "LabVIEW Magic" to pull off) is to employ a Rectangular Boolean Control (something that looks like the "Stop" button).  In fact, let's start with a Stop Button.  Place the Stop button on the Front Panel and size/move it so that it "covers" the area you want to make into your "switch".  Now all that you have to do is to make the button be "invisible".  Controls have a bunch of Properties, one of which is "Visible" -- if you set Visible to False, the button will not be Visible (duh!), but you can't "press" an "Invisible button!

 

But there's another way -- make it transparent!  Right-click the Control and bring up Properties.  Right-click the On Color, which brings down a Color Chart.  In the upper-right corner, there's a little box with "T" (for Transparent).  Select it.  Now do the same for the Off Color (no pun intended), and look at your Button.  All you should be able to see is the label, STOP.  So uncheck "Show Boolean Text".  You now have a working, but transparent (and thus not visible) Button.

 

Note that the Square Buttons in LabVIEW have a default "Latch When Released" Mechanical Action.  You need to decide if this is the behavior you want for your "button".

 

Bob Schor

 

0 Kudos
Message 3 of 15
(3,109 Views)

 

Found it.. 

it's fantastic you can size the box to any size and it that's the new area.. click inside and LED turns on.. exactly what I wanted

https://forums.ni.com/t5/Example-Programs/Determine-if-Mouse-is-within-Generic-Object-Bounds-in-LabV...

 

 

0 Kudos
Message 4 of 15
(3,088 Views)

There are many things "wrong" with the "solution" that you found, not the least that it is extremely idiosyncratic, is easily "broken" (try deleting, then un-deleting, the Decoration that defines the bounding box), and seems to require an additional "visible" rectangular object (in this case, a decoration).  If any novice LabVIEW readers follow this Post, I recommend trying my method first.

 

Bob Schor

Message 5 of 15
(3,083 Views)

@Bob_Schor wrote:

There are many things "wrong" with the "solution" that you found...


b..bu...but the example is "NI verified"! 😮

Seriously, I agree with Bob here. It is clumsy and pointless to use such a poorly scalable solution! (and why is there a vestigial timeout event???)

0 Kudos
Message 6 of 15
(3,073 Views)

Here's a quick example along my mentioned ideas. Modify as needed.

(Arguably simpler than the example referenced earlier 🐵

 

 

0 Kudos
Message 7 of 15
(3,068 Views)

Correct me if I'm wrong here, but you just turned my picture into a button? it's no longer using a bounding box. 

0 Kudos
Message 8 of 15
(3,011 Views)

@nrcan wrote:

I want the area of the screen to be assigned to a button. When you click that area of the image it will push the button. 

 

 Capture.PNG pixel area that if you click inside it will create a Boolean True.

 

 


I have done that quite a few times and it amounts first keeping track of the bonds of your "sweet spots" in the image and figuring out which of the sweet spots is closest to the mouse down location.

 

In this post in Picture Control thread, I included a link to some code that populated a picture control with an arbitrary set of images and tracking which inserted image the mouse is over.

 

If your objects are rectangular the checks amount to comparing if the mouse location is above the bottom below the top to the right of the left and to the left of the right.

 

If your object are not square then calculating the closest center to the mouse position can help.

 

Now if you objects are concave or over-lapping then life gets interesting. I will leave that for an exercise to the reader.

 

Ben

 

 

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 9 of 15
(2,996 Views)

@nrcan wrote:

Correct me if I'm wrong here, but you just turned my picture into a button? it's no longer using a bounding box. 


Yes, that's the simplest way. (or use a transparent button)

0 Kudos
Message 10 of 15
(2,973 Views)