INAppStoreWindow icon indicating copy to clipboard operation
INAppStoreWindow copied to clipboard

Issue when clicking on titlebar when in background

Open mattshepherd opened this issue 11 years ago • 7 comments
trafficstars

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 avatar Jan 09 '14 23:01 mattshepherd

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.

mattshepherd avatar Jan 13 '14 19:01 mattshepherd

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.

indragiek avatar Jan 13 '14 22:01 indragiek

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?

jakepetroules avatar Jan 19 '14 23:01 jakepetroules

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

indragiek avatar Jan 22 '14 05:01 indragiek

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.

indragiek avatar Jan 22 '14 05:01 indragiek

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 avatar Jul 26 '16 09:07 fancymax

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");
        }
    }
}

fancymax avatar Jul 27 '16 01:07 fancymax