InerziaSoft / INSDateField

A Cocoa date field edited with a calendar on a sheet beneath
3 stars 0 forks source link

Placing the date picker / calendar #2

Open daviddelmonte opened 10 years ago

daviddelmonte commented 10 years ago

Hi, I can implement everything, but I cannot get the calendar to drop under the date field. I'm trying to do this in a WindowController, rather than the AppDelegate. When I log the window, in your sample, it is loaded, in mine, it is nil. Also, in your sample, window:willPositionSheet:usingRect: is called, and in mine, not. Is there a way to force this? Thanks for any tips.

InerziaSoft commented 10 years ago

Hi David,

It seems that you have not included the DateField in a window, in your XIB file. The method you mentioned is a NSWindowDelegate method and requires the DateField to be in a window (it becomes the window's delegate to intercept the above method).

Can you, please, be more specific of where you have put the DateField?

Thank you very much!

daviddelmonte commented 10 years ago

You are right. The date field is in an nsview that is pulled in by an nswindow. I can show more when I get back to my computer.

On Feb 4, 2014, at 10:15 AM, InerziaSoft notifications@github.com wrote:

Hi David,

It seems that you have not included the DateField in a window, in your XIB file. The method you mentioned is a NSWindowDelegate method and requires the DateField to be in a window (it becomes the window's delegate to intercept the above method).

Can you, please, be more specific of where you have put the DateField?

Thank you very much!

— Reply to this email directly or view it on GitHub.

InerziaSoft commented 10 years ago

Ok, this is easy to solve! There's an IBOutlet of the INSDateField (that you can access from the XIB) called "mainWindow". If connected, that window will be used as the container window of the INSDateField.

daviddelmonte commented 10 years ago

Hi, thanks for helping (a lot of thanks). I'm attaching a screenshot. I can see the mainWindow connection. I dont know what to connect it to. If I connect to File's owner the calendar shows, but in the wrong position (about 10cm down to the left).

If I connect this to File's owner, the calendar shows On Feb 4, 2014, at 11:29 AM, InerziaSoft notifications@github.com wrote:

Ok, this is easy to solve! There's an IBOutlet of the INSDateField (that you can access from the XIB) called "mainWindow". If connected, that window will be used as the container window of the INSDateField.

— Reply to this email directly or view it on GitHub.

daviddelmonte commented 10 years ago

OK. I have it working. I just set the rect.origin manually. It works ok, but if there is a better way, that would be fine. On Feb 4, 2014, at 11:29 AM, InerziaSoft notifications@github.com wrote:

Ok, this is easy to solve! There's an IBOutlet of the INSDateField (that you can access from the XIB) called "mainWindow". If connected, that window will be used as the container window of the INSDateField.

— Reply to this email directly or view it on GitHub.

InerziaSoft commented 10 years ago

Ok, David! We've investigated a bit on this issue.

You should connect the mainWindow IBOutlet to the window you'll have your DateField into. If it is not in the same XIB, you should connect it manually via code.