LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically vertical center a button between splitters

Solved!
Go to solution

Good morning

 

Have a problem with a button in my VI. The button needs to be always in the center between the splitters.

print1.png

 

But something in the code isn't working. This is what I've done to vertically center the button:

Capturar.PNG

This code is inside a Event Structure "Panel Resize". However every time the panel resizes the button goes to top, near disappearing from screen.

Tried to get the splitters position instead of the Height of the Pane 4, but didn't worked.

 

Can you help me solve this problem?

 

My code is attached to this message.

 

0 Kudos
Message 1 of 8
(2,832 Views)
Solution
Accepted by topic author mthheitor

Origin moves because your settings is "stick to bottom"

Change it to "top"

origin.png

Message 2 of 8
(2,819 Views)

Use the Content Area Rect property to get the pane top and bottom and center the button in the middle of that area.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 3 of 8
(2,813 Views)

Sorry, didn't worked.

 

Measuring with a probe the result of the (Bottom - Top) from "ContentRect" property was the same of "Area Height"

0 Kudos
Message 4 of 8
(2,795 Views)

edit: again:

You don't just need to know the difference between the bottom and the top, you need to position relative to the top position

0 Kudos
Message 5 of 8
(2,794 Views)

Yes it does give you the same value as Area Height when you subtract them but Content Rect gives you coordinates, not dimensions.  You'll need to deal with all of the coercion dots.  

 

2018-11-19_9-30-00.png

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 6 of 8
(2,788 Views)

If you intend to do a lot of resizing and re-positioning, I would suggest that you find a toolkit on VIPM that will do these things for you.  LAVA UI Tools would be a good one.  I'm sure there are others.  This code gets a rectangle for a GObject and snaps/centers it to the left of the pane rectangle.  Very simple and clean.  

 

 2018-11-19_10-04-01.png

 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 7 of 8
(2,782 Views)

Thank you all for helping me.

 

@Artem.SPb didn't see your post. Your tip solved my problem.

 

@aputman thanks for the suggestion. I really gonna try this LAVA UI Tools

0 Kudos
Message 8 of 8
(2,731 Views)