indragiek / INAppStoreWindow

NSWindow subclass with a highly customizable title bar and traffic lights
BSD 2-Clause "Simplified" License
1.06k stars 160 forks source link

Issue when clicking on titlebar when in background #136

Open mattshepherd opened 10 years ago

mattshepherd commented 10 years ago

I was looking into using this in a project of mine and noticed and issue when you click the titlebar of the window while it is in the background and try to drag. If you click high enough where the normal title bar is it allows you to drag, if you click lower it does not drag, it just activates the window.

mattshepherd commented 10 years ago

I noticed if you use a textured window it resolves this. Might work for me since I don't need any part of the window background showing anyway.

indragiek commented 10 years ago

Yeah, it looks like using a textured window or setting movableByWindowBackground to YES are the workarounds to this issue. I'll see if there's a solution that doesn't require a workaround.

jakepetroules commented 10 years ago

Without looking at the code... IIRC, OS X has a specific dragging event, perhaps the code is only tracking mouse down, move, up, etc, instead of actual drag events?

indragiek commented 10 years ago

@jakepetroules It's using -mouseDragged:. See here: https://github.com/indragiek/INAppStoreWindow/blob/master/INAppStoreWindow/INAppStoreWindow.m#L446

indragiek commented 10 years ago

I think I recall from past experience that there was some funky behaviour with -mouseDragged: not being called when the drag is initiated while the app is not active. I'll take a look when I get a chance.

fancymax commented 8 years ago

I had fix this. @mattshepherd @indragiek @jakepetroules @tonyarnold @robin

- (void)becomeKeyWindow
{
    // repost the first NSLeftMouseDown event filter by NSWindow
    [self postEvent:[self currentEvent] atStart:true];
    [super becomeKeyWindow];
    [self _updateTitlebarView];
    [self _updateBottomBarView];
    [self _layoutTrafficLightsAndContent];
    [self _setupTrafficLightsTrackingArea];
}

refer by Cocoa Event Handling Guide,so repost the event fix the problem.

Some events, many of which are defined by the Application Kit (type NSAppKitDefined), have to do with actions controlled by a window or the application object itself. Examples of these events are those related to activating, deactivating, hiding, and showing the application. NSApp filters out these events early in its dispatch routine and handles them itself.

fancymax commented 8 years ago

or you can repost the event in NSWindowDelegate's notification

- (void)windowDidBecomeKey:(NSNotification *)notification {
    NSEvent *theEvent = [self.window currentEvent];
    if (theEvent != nil) {
        if(theEvent.type == NSLeftMouseDown){
            [self.window postEvent:theEvent atStart:true];
            NSLog(@"repost LeftMouseDown event");
        }
    }
}