Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allow click and dragging a view to drag the window itself?

Tags:

I'm using a textured window that has a tab bar along the top of it, just below the title bar.

I've used -setContentBorderThickness:forEdge: on the window to make the gradient look right, and to make sure sheets slide out from the right position.

What's not working however, is dragging the window around. It works if I click and drag the area that's actually the title bar, but since the title bar gradient spills into a (potentially/often empty) tab bar, it's really easy to click too low and it feels really frustrating when you try to drag and realise the window is not moving.

I notice NSToolbar, while occupying roughly the same amount of space below the title bar, allows the window to be dragged around when the cursor is over it. How does one implement this?

Thanks.

Tab Bar

like image 856
d11wtq Avatar asked Dec 30 '10 15:12

d11wtq


People also ask

How do I drag and drop with mouse?

To move an object, place the mouse cursor over it, press and hold down the left mouse button, then move the mouse while still holding down the left mouse button. When you have "dragged" the object to the location you want, let go of the mouse button.


1 Answers

I tried the mouseDownCanMoveWindow solution (https://stackoverflow.com/a/4564146/901641) but it didn't work for me. I got rid of that method and instead added this to my window subclass:

- (BOOL)isMovableByWindowBackground {     return YES; } 

which worked like a charm.

like image 191
ArtOfWarfare Avatar answered Dec 07 '22 04:12

ArtOfWarfare