Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
650 views
in Technique[技术] by (71.8m points)

cocoa - NSTableView with Plus and Minus buttons

How can I do something like that?

Screenshot

I didn't find any appropriate object in the Interface Builder library.

Any thoughts?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The best way that i found is to use NSSegmentedControl.

after you dragged it on the canvas, you should configure its style:

Style: Small Square
Mode:  Select Momentary

looks better. Now use "image" field to set NSAddTemplate and NSRemoveTemplate. Make sure that label field is empty.

Ok, we have "+", "-" and one empty segment. To prevent the latest one to be selected by the user, select it from Segment: pop up and turn off Enabled check box (located next to State: label).

And lastly, what we have to do is set width of first two segments to make them square.

  1. Go to Size inspector
  2. Select Segment 0
  3. Turn off "Fixed" checkbox (segment should immediately autoresize to fit image)
  4. Select Segment 1 and repeat number 3
  5. Now as you resize control, only last segment will change width
  6. Put it at the bottom of your table view and resize as well.

Enjoy ;)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...