discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GUI incompatibility


From: Andreas Höschler
Subject: Re: GUI incompatibility
Date: Wed, 13 May 2020 23:52:56 +0200

Hi Fred,

thanks for pointing me into the right direction. I got this figured out in the meanwhile. You do

- (void) sendEvent: (NSEvent*)theEvent
{
...
              if (_lastLeftMouseDownView)
                {
                  DESTROY(_lastLeftMouseDownView);
                }
              // Don't make buttons first responder otherwise they cannot 
              // send actions to the current first responder.
              // TODO: First responder status update would more cleanly 
              // handled by -mouseDown in each control subclass (Mac OS X 
              // seems to do that).

              if (_firstResponder != v && ![v isKindOfClass: [NSButton class]])
                {
                  // Only try to set first responder, when the view wants it.
                  if ([v acceptsFirstResponder] && ![self makeFirstResponder: v])
                    {
                      NSLog(@"Leaving early");
                      return;
                    }
               }

              if (wasKey == YES || [v acceptsFirstMouse: theEvent] == YES)
                {
                  if ([NSHelpManager isContextHelpModeActive])
                    {
                      [v helpRequested: theEvent];
                    }
                  else
                    {
                      ASSIGN(_lastLeftMouseDownView, v);
                      if (toolTipVisible != nil)
                        {
                          /* Inform the tooltips system that we have had
                           * a mouse down so it should stop displaying.
                           */
                          [toolTipVisible mouseDown: theEvent];
                        }
                      [v mouseDown: theEvent];
                    }
                }
              else
                {
                    [self mouseDown: theEvent];
                }
            }
          else
            {
              NSDebugLLog(@"NSEvent", @"Discard (window closed) %@", theEvent);
            }
          _lastPoint = [theEvent locationInWindow];
...
}

I understand the idea behind this part

if (_firstResponder != v && ![v isKindOfClass: [NSButton class]])
                {
                  // Only try to set first responder, when the view wants it.
                  if ([v acceptsFirstResponder] && ![self makeFirstResponder: v])
                    {
                      NSLog(@"Leaving early");
                      return;
                    }
               }

but would suggest that this is not entirely correct. My FormTextField refuses to become first responder on purpose but nevertheless relies on seeing a mouseDown: call. I use that to activate an inspector. At another place in the code this mouseDown: is needed to initiate a drag operation to drag the gui element around. Cocoa does this correctly IMHO (sends the mouseDown:).

I could fix the problem under GNUstep by simply commenting out


/*              if (_firstResponder != v && ![v isKindOfClass: [NSButton class]])
                {
                  // Only try to set first responder, when the view wants it.
                  if ([v acceptsFirstResponder] && ![self makeFirstResponder: v])
                    {
                      return;
                    }
                }
*/

Does anything speak against submitting this change into the public tree?

Thanks,

 Andreas


On 13 May 2020, at 21:15, Fred Kiefer <fredkiefer@gmx.de> wrote:

The relevant section in the sendEvent: method of NSWindow looks like this:


             if (wasKey == YES || [v acceptsFirstMouse: theEvent] == YES)
               {
                 if ([NSHelpManager isContextHelpModeActive])
                   {
                     [v helpRequested: theEvent];
                   }
                 else
                   {
                     ASSIGN(_lastLeftMouseDownView, v);
                     if (toolTipVisible != nil)
                       {
                         /* Inform the tooltips system that we have had
                          * a mouse down so it should stop displaying.
                          */
                         [toolTipVisible mouseDown: theEvent];
                       }
                     [v mouseDown: theEvent];
                   }
               }

Looks like we only call acceptsFirstMouse when the window was not already key. If this isn’t what Cocoa does, you need to explain the expected behaviour.
This code looks like it is there on purpose but Apple may have changed their implementation or documentation in the meantime.

Cheers,
Fred


Am 13.05.2020 um 17:37 schrieb Andreas Höschler via Discussion list for the GNUstep programming environment <discuss-gnustep@gnu.org>:

Hi Fred,

I am still trying to get my apps to work under GNUstep. I have already worked around a couple of incompatibilities between Cocoa and GNUstep that caused trouble.

I now ended up at the following problem:

I have some NSView subclass on a window

ValueElementCarrier : ElementCarrier : ComponentCarrier : ControlCarrier : NSView

ValueElementCarrier has a subview

   FormTextField : NSTextField

over its complete rect.

@implementation FormTextField

- (void)mouseDown:(NSEvent *)theEvent
{
  NSLog(@"%@ mouseDown ..", self);
   ...
   [super mouseDown:theEvent];
}

- (BOOL)becomeFirstResponder
{
  BOOL result = ([(FBFormWindow *)[self window] designMode] ? NO : [super becomeFirstResponder]);
  NSLog(@"%@ becomeFirstResponder %d", self, result);
  return result;
}

- (BOOL)acceptsFirstMouse: (NSEvent*)theEvent
{
  BOOL result = [super acceptsFirstMouse:theEvent];
  NSLog(@"%@ acceptsFirstMouse %d", self, result);
  return result;
}

@end


When I click on this FormTextField on MacOSX I get

13/05/20 17:23:40,783 InterfaceBuilder[93679]: <FormTextField: 0x102cd30> acceptsFirstMouse 1
13/05/20 17:23:40,783 InterfaceBuilder[93679]: <FormTextField: 0x102cd30> becomeFirstResponder 0
13/05/20 17:23:40,784 InterfaceBuilder[93679]: <FormTextField: 0x102cd30> mouseDown ..

When I do the same on GNUstep I get

13/05/20 17:23:40,783 InterfaceBuilder[93679]: <FormTextField: 0x102cd30> becomeFirstResponder 0

but no call of acceptsFirstMouse and no call of mouseDown!?  This renders my up inoperable! :-(

Any idea? Should this behaviour be fixed in GNUstep (handled equally)?

Thanks,

Andreas











reply via email to

[Prev in Thread] Current Thread [Next in Thread]