2

Im trying to create a text field with a calendar pop just like you see in the Calendar App of MacOS:

Calendar pop

I imagined it would be something native, but can't quite find how to implement it for MacOS. If you could give me tips of which elements are being used I appreciate.

Tassio Marques
  • 81
  • 1
  • 10
  • Hope this blog might help you:http://www.knowstack.com/swift-nsdatepicker-sample-code/ and source can be [downloaded here](http://www.knowstack.com/wp-content/uploads/2016/02/NSDatePickerSampleCode.zip) – Raviprakash Jun 09 '18 at 17:42

1 Answers1

3

I implemented such a functionality in one of my Apps. There is nothing native available in macOS. To get this behavior you can use a border less window with a custom shape. The window can be opened relative to the view triggering the action. In the window you can use a regular NSDatePicker.

enter image description here

Let me know if you need further help.

Sample code on GitHub

All the best.

Marc T.
  • 5,090
  • 1
  • 23
  • 40
  • Hey, thanks for commenting. I have a question for you: Is it possible to make a window relative to a view or another window? How did you manage to do that? I was able to do it by creating a view on top of another view. Which for me, it is not the most elegant solution, but it works. – Tassio Marques Jun 11 '18 at 09:14
  • To use a view is not a good idea. The window approach is how its done by Apple as well. Unfortunately is my code still in objective-c but I will migrate it to Swift and make the code available for you. – Marc T. Jun 11 '18 at 19:06
  • 1
    Unfortunately it took some longer to migrate the code to swift but finally its there. I updated my answer with the link – Marc T. Jun 17 '18 at 13:03