Creating Panels at Screen boundaries
===

I have a control where when a button is pressed a new NSPanel is popped up and this panel contains a slider as shown in the image below:

![enter image description here][1]


Now When my application's window is in such a position that the Push Button is half in the screen bounds and half outside of the screen bounds, then the **NSPanel** PopUp gets displayed half inside of the screen bounds and half outside of the screen bounds as shown in image below:

![enter image description here][2]


  [1]: http://i.stack.imgur.com/6o8FM.png
  [2]: http://i.stack.imgur.com/vPfe0.png

Below is the code I am using to create the **NSPanel**<br>

        // Convert Co-ordinates of button to screen coordinates
        NSRect buttonFrame = [[sender window]convertRectToScreen:[sender frame]];
        // Create new window for the slider
        NSRect windowRect = NSMakeRect(buttonFrame.origin.x, buttonFrame.origin.y, 26, 118);
        newPanel = [[NSPanel alloc]initWithContentRect:windowRect styleMask:NSUtilityWindowMask backing:NSBackingStoreBuffered defer:FALSE];

<br>
Can anyone suggest a way, how can I ensure that whenever the **NSPanel** is created, it is created in the screen bounds only.