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
(3,456 Views)
Solution
Accepted by mthheitor

Origin moves because your settings is "stick to bottom"

Change it to "top"

origin.png

Message 2 of 8
(3,443 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
0 Kudos
Message 3 of 8
(3,437 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
(3,419 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
(3,418 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
0 Kudos
Message 6 of 8
(3,412 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
Message 7 of 8
(3,406 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
(3,355 Views)