Hello, I have an NSView that draws a chromatogram (a curve) and also draws text labels above the tip of peaks (the text represents the x location of the peak). I'm currently using NSTextField instances as subviews of the chromatogram view for these labels, and it seems to work.
However, the Apple documentation suggests NSCell should be more adapted to draw text in a view ("lighter" than NSControl, they say). But I can't get how it's supposed to work. I tried to create cells and send -drawWithFrame:inView: to them, but they seem to draw in the window coordinate (even though the inView: argument is the chromatogram view) so they show outside the view. I don't even know exactly when I should call this method either (assuming it's the right method). Should I call it within the view -drawRect: method? Should I subclass NSCell and override some methods? NSTextField instances draw themselves, so I don't have to worry about it, I just have to set their frame so they draw at the right spot. But for NSCell... I don't know how.
The labels should ultimately react to mouse event and send actions... which is why I'm not simply drawing strings with -drawAtPoint:
So, should I use NSCell (if so, how?) or is NSTextField the best solution?
Thanks.
However, the Apple documentation suggests NSCell should be more adapted to draw text in a view ("lighter" than NSControl, they say). But I can't get how it's supposed to work. I tried to create cells and send -drawWithFrame:inView: to them, but they seem to draw in the window coordinate (even though the inView: argument is the chromatogram view) so they show outside the view. I don't even know exactly when I should call this method either (assuming it's the right method). Should I call it within the view -drawRect: method? Should I subclass NSCell and override some methods? NSTextField instances draw themselves, so I don't have to worry about it, I just have to set their frame so they draw at the right spot. But for NSCell... I don't know how.
The labels should ultimately react to mouse event and send actions... which is why I'm not simply drawing strings with -drawAtPoint:
So, should I use NSCell (if so, how?) or is NSTextField the best solution?
Thanks.