0
votes

NSButton is ignoring clicks that come in too close together.

If I click slowly, all clicks are acknowledged, but if I start to speed up, at a certain point it will stop sending mouseDown: events anymore. If I then slow it down, at a certain point all clicks begin to propogate again.

For a couple of the buttons in this app, hammering will happen, and there's no reason it shouldn't be allowed.

I've tried setIgnoresMultiClick:, but it doesn't change the behavior.

I tried subclassing NSButton, overriding mouseDown:, recreating a duplicate of the event object except with the button count set to 1.

Still no dice.

Anyone know the trick here?

SEMI-Resolved (...though w/ drawbacks).

There are probably a half dozen ways to do this, but here's how I enabled button hammering...

@interface HammerClickWindow : NSWindow {;;}
@end

@implementation HammerClickWindow
- (void)sendEvent:(NSEvent *)event
{
    if ( event.type == NSLeftMouseDown )
    {
        [super sendEvent:[NSEvent mouseEventWithType:event.type location:event.locationInWindow modifierFlags:event.modifierFlags timestamp:event.timestamp windowNumber:event.windowNumber context:event.context eventNumber:event.eventNumber clickCount:1 pressure:event.pressure]];
    }
}
@end

If anyone knows how to do this where it (A) doesn't effect 100% of mouse downs in a window, and (B) can effect only specific buttons... that'd be great.

1
Since UI work on main thread the thread would be blocked until the action is complete so in that duration it wouldn't respond to other clicks I guess.Pushpak Narasimhan
Hmmm... You know, that's interesting. The buttons that I'm using are simple NSButtons hooked to IBActions, but they're behaving like this. I just added a new vanilla NSButton to the same window in the same project, hooked up its IBAction and sure enough, the IBAction method gets called every time no matter how fast I click. So why are my other buttons behaving like this? They have custom images, but that's about it.AJ.DE
So it appears to have something to do with calling setHidden:YES on the button that triggered the action in the action. There is a '+' button which opens a view. There is an 'x' (close) button in the corner of the view. The two buttons are directly over one another so after clicking '+' and opening the view, i hide the '+' button, when the user clicks the 'x' button to close the view, the '+' button is unhidden again. I might need to rethink how the UI is laid out. The more I describe it, the more non-standard I realize it is.AJ.DE

1 Answers

0
votes

You need to make change into System Preferences - Mouse - Double-Click Speed - Fast