FROM : Matt Gemmell
DATE : Sun Jan 26 14:21:31 2003
On Saturday, January 25, 2003, at 07:08 pm, Matt Gemmell wrote:
> 1. The first method does not position the menu consistently, since
> it's just popping up a menu as if the user has control-clicked. I want
> the menu to always appear such that its top-left is just below the
> view's bottom-left point; i.e. the way that a menu appears relative to
> its title in the menubar.
Solved by creating a new NSEvent with the same values as the received
event in mouseDown:, except that I passed in my own location value (the
origin of my NSButton subclass' frame), like this:
- (void)mouseDown:(NSEvent *)theEvent
{
[self highlight:YES];
NSEvent *click = [NSEvent mouseEventWithType:[theEvent type]
location:[self frame].origin
modifierFlags:[theEvent
modifierFlags]
timestamp:[theEvent timestamp]
windowNumber:[theEvent windowNumber]
context:[theEvent context]
eventNumber:[theEvent eventNumber]
clickCount:[theEvent clickCount]
pressure:[theEvent pressure]
];
[NSMenu popUpContextMenu:[self menu] withEvent:click forView:self];
}
That makes the menu appear in the proper position every time.
> 2. Both methods don't perform highlighting of the image (the usual
> grey semi-transparent overlay which indicates a control is active).
> Similarly, they don't dim when disabled.
Solved by using an NSButton subclass, setting it to have no border,
setting it to highlight by NSNoCellMask, and letting it draw itself -
thanks to Rudis Muiznieks.
Source to follow soon on my site.
Best,
-Matt
--
Matt Gemmell
Scotland Software
http://www.scotlandsoftware.com/
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
DATE : Sun Jan 26 14:21:31 2003
On Saturday, January 25, 2003, at 07:08 pm, Matt Gemmell wrote:
> 1. The first method does not position the menu consistently, since
> it's just popping up a menu as if the user has control-clicked. I want
> the menu to always appear such that its top-left is just below the
> view's bottom-left point; i.e. the way that a menu appears relative to
> its title in the menubar.
Solved by creating a new NSEvent with the same values as the received
event in mouseDown:, except that I passed in my own location value (the
origin of my NSButton subclass' frame), like this:
- (void)mouseDown:(NSEvent *)theEvent
{
[self highlight:YES];
NSEvent *click = [NSEvent mouseEventWithType:[theEvent type]
location:[self frame].origin
modifierFlags:[theEvent
modifierFlags]
timestamp:[theEvent timestamp]
windowNumber:[theEvent windowNumber]
context:[theEvent context]
eventNumber:[theEvent eventNumber]
clickCount:[theEvent clickCount]
pressure:[theEvent pressure]
];
[NSMenu popUpContextMenu:[self menu] withEvent:click forView:self];
}
That makes the menu appear in the proper position every time.
> 2. Both methods don't perform highlighting of the image (the usual
> grey semi-transparent overlay which indicates a control is active).
> Similarly, they don't dim when disabled.
Solved by using an NSButton subclass, setting it to have no border,
setting it to highlight by NSNoCellMask, and letting it draw itself -
thanks to Rudis Muiznieks.
Source to follow soon on my site.
Best,
-Matt
--
Matt Gemmell
Scotland Software
http://www.scotlandsoftware.com/
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
| Related mails | Author | Date |
|---|---|---|
| Matt Gemmell | Jan 25, 20:08 | |
| Matt Gemmell | Jan 26, 14:21 |






Cocoa mail archive

