3

i have an NSComboBox that displays text not vertically aligned. Is there a method to vertical align text inside an NSComboBox?

enter image description here

As you can see, it's very strange and it doesn't change on fontsize basis. I've searched NSComboBox Class Reference but the only resource available is for the popup displayed items (like intercellSpacing or setItemHeight:).

Thank you in advance.

NSGod
  • 22,699
  • 3
  • 58
  • 66
Val K.
  • 113
  • 1
  • 10
  • I realise this is 8 years ago so probably well in the back of your mind but did you ever crack this please? I'm having a similar issue! – ADB Oct 09 '21 at 11:04

1 Answers1

1

try:

NSComboBox* cbx = ZGKeyComboBox.new;
// NSViewMaxYMargin means: The top margin between the receiver and its superview is flexible.
cbx.autoresizingMask = NSViewMaxYMargin;
cbx.itemHeight = cbx.itemHeight + 3; // addSubview will center vertically
NSRect r = NSMakeRect(x, y, width, cbx.itemHeight + 5);
cbx.frame = r;
...
[parent addSubview: cbx];
Leo
  • 790
  • 8
  • 10