discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSComboBox : how to set the width properly ?


From: Fred Kiefer
Subject: Re: NSComboBox : how to set the width properly ?
Date: Sat, 21 May 2005 16:00:27 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.7) Gecko/20050414

Stéphane Goujet wrote:
I believe the recommended way to fix the dimensions of a NSComboBox is to find the widest element in the list and give its width to the NSComboBox. But there comes a problem : the NSComboBox interprets it as its total width, including the text field AND the button.

I think this part is correct. The frame has to include both components. Your problem when setting it from the outside is that you have no way of knowing the size of the button (currently hardcoded 17x17).

It is the same if one uses the sizeToFit method. I find that totally illogical : NSComboBox calculates the width to fit on the text field, but then it does not use it to set its own text field width... instead it substracts from it the button width. So a sizeToFit never fits, the end of the text is hidden by the button...

This seems to be a real problem. NSComboBoxCell does not implement the method cellSize, which should return the optimal size for the text cell plus the button. Quentin, are you going to implement this? If you don't have time, I could give it a try. In a first step, I would not loop over all the elements, but just return the two control sizes added up.

  What is the work-around ?
For example, how to know the width of the button ? Then I could add it to the frame width and do a setFrame. I saw those values are hardcoded in NSComboBoxCell.m, so I could copy them, but isn't there a proper way to get them ?

Not that I know of.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]