The method preventWindowOrdering is a NOOP on GNUstep, so it won’t help you. Put if this is what helps you on MacOS then most likely your touch panel is stealing the focus. You should try to override canBecomeKeyWindow for that panel.
There is no designated touch panel. I have a one window app (full screen) with some controls (NSTextField, NSComboBox,...) and at the bottom of the window the keys A, B, C, ...
So the window will definitely be key (have to). In this window I want an NSTextField to keep firstResponder when clicking on one of the keyboar keys!?
Hope this help,
Am 30.03.2020 um 19:13 schrieb Andreas Höschler <address@hidden>:
Am 30.03.2020 um 15:19 schrieb Andreas Höschler <address@hidden>:
in NSButton you find this code:
- (BOOL) acceptsFirstMouse: (NSEvent *)theEvent
You will need to write a subclass to handle this different.
Thanks a lot for your response. I created a subclass KbButton and overwrote this method like so
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
NSLog(@"%@ returns acceptsFirstMouse NO", self);
When I click on the button the currently active NSTextField looses first responder and the action of the button is called
30/03/20 14:42:16,912 ScaleMaster: strike sender <KbButton: 0x7b82ae50> stringValue A
The method acceptsFirstMouse: of KbButton is never called. So this unfortunately does not work, at least not on MacOSX (dev machine for the project). :-( I will port the code to GNUstep and see whether GNUstep behaves differently. Will let you know ...
Well, yes. I'm afraid Fred's advice is wrong (even though . While the code in -[NSWindow sendEvent:] indeed requires The method acceptsFirstMouse is supposed to serve a different purpose. When you activate window by clicking onto it, acceptsFirstMouse governs whether this click is passed to the control under the mouse (acceptsFirstMouse returns YES) or whether it is only for activating the window (acceptsFirstMouse returns NO). Your original approach calling setAcceptsFirstResponder: with NO looks right to me. It is just that the code in -[NSEvent sendEvent:] gets the logic wrong. Where it currently says
if ([v acceptsFirstResponder] && ![self makeFirstResponder: v])
it should really say
if (![v acceptsFirstResponder] || ![self makeFirstResponder: v])
I got this working on MacOSX by subclassing NSButton and doing
- (void)mouseDown:(NSEvent *)theEvent
NSEvent *mouseUpEvent = [[self window] nextEventMatchingMask:NSLeftMouseUpMask
untilDate:[NSDate distantFuture] inMode:NSEventTrackingRunLoopMode dequeue:YES];
NSPoint mouseLocation = [self convertPoint:[mouseUpEvent locationInWindow] fromView:nil];
BOOL mouseUpInside = [self mouse:mouseLocation inRect:[self bounds]];
if ([self target])
[[self target] performSelector:[self action] withObject:self];
I haven't tested that on the GNUstep machine yet. But if it worked there as well this would make my day.
Mit freundlichen Grüßen, Andreas HöschlerManaging Director Smartsoft GmbH
Birkenweg 11aD-21483 Gülzow Phone 040 22820930-0Fax 040 22820930-9Web http://www.smartsoft.deEmail: address@hidden Steuernummer: 44/759/00826Amtsgericht Hamburg, HRB 117172Geschäftsführer: Andreas Höschler