*WORKAROUND* Re: Buttons work under 10.3.4 but not 10.2.8
*WORKAROUND* Re: Buttons work under 10.3.4 but not 10.2.8
- Subject: *WORKAROUND* Re: Buttons work under 10.3.4 but not 10.2.8
- From: Tim Hewett <email@hidden>
- Date: Sat, 26 Jun 2004 21:53:08 +0100
Although the problems with contextual menus not working in modal
windows isn't solved or worked around, the problem with buttons
in drawers attached to modal panels in 10.2.8 has been worked around.
Just subclass the buttons in such a drawer and overload mouseDown:
to catch the click, highlight the button, wait for the mouse to be
released,
then call the action method on the target. Although the buttons don't
call the action when clicked, they do get the mouseDown event, so
just do yourself what is supposed to happen in Cocoa.
Here is the code which works for me:
@implementation MyButton
- (void)mouseDown:(NSEvent *)theEvent
{
while ([theEvent type] != NSLeftMouseUp) {
[self highlight:YES];
theEvent = [[self window] nextEventMatchingMask:
NSLeftMouseUpMask];
switch ( [theEvent type] ) {
case NSLeftMouseUp:
[self highlight:NO];
objc_msgSend( [self target], [self action], self ); // call
the action method when mouse released
break;
default:
[super mouseDown:theEvent];
break;
}
}
}
@end
It seems to me that some of the peripheral functionality associated with
modal windows is broken in 10.2.8, and to a slightly lesser extent in
10.3.4.
Hopefully the alleged new focus on reliability (over functionality) for
the
new OS 10.4 will check out this area ;-)
Regards,
Tim Hewett, Coolatoola.com
On 8 Jun 2004, at 10:08, email@hidden wrote:
>
Hi,
>
>
This problem with buttons in a drawer not working is getting
>
stranger...
>
I'd wondered whether there was some small incompatibility when
>
an Interface Builder created GUI made under 10.3 was run under 10.2,
>
but IB seems to be irrelevant.
>
>
First, running IB under 10.2.8 I deleted and recreated/reconnected the
>
buttons, in case the 10.2.8 IB would do something different to 10.3's.
>
They still just generated a system beep when clicked. I've since had
>
the
>
buttons print out their target object pointers and they are all setup
>
fine
>
under both 10.2. and 10.3. Now the target and actions of all three
>
buttons are manually set to be what they should be, in case the
>
buttons aren't being instantiated correctly, and still just the system
>
beep without the action method being called.
>
>
The buttons are definitely "there", they can be controlled as outlets,
>
e.g. setEnabled: works just fine, the buttons grey and ungrey as they
>
should. It is just the actions when the buttons are clicked, under
>
10.2.8
>
they do nothing.
>
>
Any insights as to what is causing this would be very much appreciated.
>
>
Regards,
>
>
Tim Hewett, Coolatoola.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.