brigadir
brigadir

Reputation: 6942

NSButton with image - how to get image subview?

I can't find, how to get image subview from NSButton. I need it to get actual image scale.

Upvotes: 1

Views: 761

Answers (2)

Anoop Vaidya
Anoop Vaidya

Reputation: 46533

You can loop through the button subview and you will see NSImageView & NSTextfield. Something like this pseudo code:

foreach (NSView view in Subviews)
                if (view.GetType() == typeof(NSImageView))
                    imageView = (NSImageView)view;
                else if (view.GetType() == typeof(NSTextField))
                    textField = (NSTextField)view;

Upvotes: 0

hamstergene
hamstergene

Reputation: 24429

There is no subview, it is painted by button cell. Use e.g. -[NSCell imageRectForBounds:] to get information about its position.

Upvotes: 3

Related Questions