ChristianLinnell
ChristianLinnell

Reputation: 1398

How do I get controls to draw outside a window in Objective C

I've got a search-suggestion box that I've implemented by using an NSScrollView that appears when you start typing in an NSTextField. I'd like my window to be quite short, and have the ScrollView draw partially outside the window. Like this:

enter image description here

But instead I get this:

enter image description here

What can I do?

Upvotes: 0

Views: 150

Answers (1)

Ken Thomases
Ken Thomases

Reputation: 90681

You can't have controls that extend outside of a window. What you need to do is put them in a separate window. You generally want that window to be a child of the original window (using -[NSWindow addChildWindow:ordered:]).

For the use case you describe, you should use the built-in control, NSComboBox. If you really want to reimplement this sort of control, Apple provides the CustomMenus sample code and a related WWDC video. It specifically includes a suggestions menu to help fill in a text field.

Upvotes: 2

Related Questions