Custom tooltip that can overhang NSWindow? - objective-c

I need to create a custom tooltip for my app yet I want it to act like a normal tooltip and overhang the top level window if the cursor is near the bottom or right edges. Do I need to make the tooltip control an NSWindow itself or is there a way to get an nsview to pop outside the window bounds.

So the solution for this was to create an NSPanel that is setFloatingPanel:YES. On mouse enter of the view I call orderToFront on the panel, on mouse move I setFrameOrigin and on mouse exit I orderOut.

Related

pyglet window resize - problem when maximizing / restoring window

I am building a simple menu bar for my Pyglet app. I would like to stick the menu on the top left corner of the window, and also I would like my menu to have the same width of the window but fixed height.
So what I've done is to add a local_on_resize method that calls my menu resize method that performs all the necessary transformations.
def local_on_resize(self, x, y):
self.menu.resize(self.width, self.height)
and this method is pushed in this way in the window constructor:
self.push_handlers(on_resize=self.local_on_resize)
This seemed to work, as if I try to resize the window by dragging the borders of my window the menu gets resized correctly. The problem comes when I try to maximize/restore my window. In fact when I click on the maximize button the window gets maximized but I get a black screen (the menu bar disappears). However, if I try to click anywhere, or raise any event, the menubar reappears correctly. Same thing for restore button: if I restore my window, the menubar disappears but it gets back if I click on the window. So what I see if that the resize mechanism seems to work when I resize the window "continuously" by dragging it, but doesn't work when I maximize/restore it.
Does anybody know how can I fix this?

Set correct cursor when a button overlays a scroll/text view?

My storyboard includes a scroll view (uneditable but selectable) that is overlaid with a second view containing a couple of buttons which are initially visible and eventually hidden. As I move the mouse over the scroll view, the text cursor displays as expected. But when the mouse moves over the buttons, the text cursor remains. I would have expected the cursor to change to an arrow.
What is the proper way to make the arrow cursor appear when over the buttons, when overlaying a scroll view? Can this be done within the storyboard or am I missing some code?
Thanks!

Resize NSWindow from bottom left corner only?

I am writing an application that sits in the OS X menu bar and when you press its icon a little NSPanel opens up. I would like the user to be able to resize it, but only by dragging the bottom left corner. I want to prevent them from being able to drag the top edge down and "unstick" the window from the menu bar.
Just override touchesBegan mouseDown: and pass on the drag only if it is in the designated corner, discarding other touches.
See Cocoa Event Handling Guide

UIButton with custom shadow image

I need to achieve effect of my button like this:
My questions are:
How can I add this custom shadow to button, so only 'BUTTON' surface reacts for touches?
When I have the next button in the bottom, close to previous one, how can I be sure that it will not be covered by upper's button shadow?
I need to have all the buttons in front and all the shadows in the back.
If you want to add the shadow without having it clickable, you need to add an imageView to as a subview to the button. (make sure clip subviews is disabled).
If you want the shadow of one button not appearing on top of the other, then you need to have the shadow(s) added separately to the main parent view. The solution in option 1 will not work. Its not neat, but its the only way i can think off.

cocoa mousedown on a window and mouse up in another

I am developping a Cocoa application and I have a special need. In my main window, when I mouse down on a certain area, a new window (like a complex tooltip) appears. I want to be able to do:
- mouse down on the main window (mouse button stay pressed)
- user moves the mouse on the "tooltip" window and mouseup on it.
My issue is that the tooltip window does nto get any mousevent until the mouseup.
How can I fix this?
Thanks in advance for your help,
Regards,
And it won't since mouse is tracked by the main window. However, you can process mouseUp in the main window, transform click coordinates into the desktop space, get tooltip window frame and check whether the click occurred on the tooltip. After that, you can send a message to the tooltip window manually.
Or you can try to find another way to implement the final goal :) It is usually better to follow the rules, in this case - mouse tracking.