Re: How to build a popup menu and show this menu?
Re: How to build a popup menu and show this menu?
- Subject: Re: How to build a popup menu and show this menu?
- From: "Alan Smith" <email@hidden>
- Date: Thu, 23 Feb 2006 19:56:51 -0600
I would have written sooner but w/ the digest mode you don't get the
emails as soon as they're sent.
I was working with menus a while ago, and ended up using a sweet class
called PopUpImage. It was a subclass of PopUpButton, or whatever it's
called, you would specify the menu image and the image for the little
arrow that points down/over. You would then add items and each had
it's own selector. This was all done programmaticlly. You could use
this but it's not quite what you're looking for, by my understanding
anyway.
By what I understand you want a button that pops up a "palette", which
by the sound of it is like the tool palette in Photoshop, but you also
want it to be like a menu in the way that in pops up right next to, or
on top of, the button.
Not having a computer on hand that has the dev tools on it hasn't
helped my planning with this. After some thought, I came up with this.
You make a subclass of NSButton. You override the mouseDown:, or
whichever, and you have it draw a NSView on the button. Without a
title bar of cource. I have some idea of how to do all this and here's
how I'd start out.
- (void)mouseDown:
{
NSRect theOrigin = [theView frame];
theOrigin.origin.x = ([theButton frame].size.width / 2);
theOrigin.origin.y = ([theButton frame].size.height / 2);
[theView setFrame:theOrigin];
[theView showWindow];
}
Now if I did it right that will display the view in the center of the
button, I don't know which corner of the view is positioned at the
center of the button.
You will of course have to subclass the view to make it title-bar
less. If you're going to put buttons in it will start to get
complicated. You'll have to subclass another NSButton. It would also
have to override the mouseDown:. If it gets pressed it would then
close it's superview.
- (void)mouseDown;
{
[[theButton superview] setHidden: YES];
}
You may need to add the action of the button or whatever. Uh… no… it
should be ok as long as you have it attached to an action; I think.
You'll have to try it and find out, I'm not sure.
If I had a computer around that has the dev tools I'd have tried it
before I wrote to you.
If you do try it, let me know how it went.
Cheers, Alan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden