Adding HUD context pannel to rows within NSOutlineView
-
Hey All
What I would like to end up with is on my outline view (that already
works no problems), when the user right-clicks one of the rows, I
would like that one to become the selected row, and a context menu to
popup beside, from which I can set some parameters. I have read about
the menu outlet, but im not sure if thats the right way to go, and
even if it is, what it needs to be connected to?
Can anyone point me in the right direction? Any help at all would be
greatly appreciated :)
Cheers
Tim -
One approach is to override -menuForEvent: in your subclass of
NSOutlineView, there creating and populating an NSMenu. You might
consider delegating the task of populating the menu to the selected
item or to the outline view's delegate...
dave
On 28-Nov-07, at 5:29 AM, Tim Perrett wrote:
> Hey All
>
> What I would like to end up with is on my outline view (that
> already works no problems), when the user right-clicks one of the
> rows, I would like that one to become the selected row, and a
> context menu to popup beside, from which I can set some parameters.
> I have read about the menu outlet, but im not sure if thats the
> right way to go, and even if it is, what it needs to be connected to?
>
> Can anyone point me in the right direction? Any help at all would
> be greatly appreciated :)
>
> Cheers
>
> Tim
>
-
>
> What I would like to end up with is on my outline view (that already
> works no problems), when the user right-clicks one of the rows, I
> would like that one to become the selected row, and a context menu
> to popup beside, from which I can set some parameters. I have read
> about the menu outlet, but im not sure if thats the right way to go,
> and even if it is, what it needs to be connected to?
>
> Can anyone point me in the right direction? Any help at all would be
> greatly appreciated :)
Tim,
On Leopard, NSTableView/NSOutlineView has been enhanced to make this
very easy to do. The AppKit release notes have some information on it,
and the DragNDropOutlineView demo app in developer/examples/appkit has
an example on how to do it.
corbin -
Hey Corbin
Thanks for the reply. Ive been looking at the DragNDropOutlineView
example, and I found this comment
"On MacOS 10.5 and later, in willDisplayCell: we can dynamically set
the contextual menu (right click menu) for a particular cell. If
nothing is set, then the contextual menu for the NSOutlineView itself
will be used. We will set a different menu for the "Expandable?"
column, and leave the default one for everything else."
Which Im guessing is what you meant about making it easier in 10.5?
Isn't that using NSMenu however? rather than a panel which I belie
those little HUD windows are?
Thanks
Tim
On 28 Nov 2007, at 16:54, Corbin Dunn wrote:
> Tim,
> On Leopard, NSTableView/NSOutlineView has been enhanced to make this
> very easy to do. The AppKit release notes have some information on
> it, and the DragNDropOutlineView demo app in developer/examples/
> appkit has an example on how to do it.
>
> corbin
-
On Nov 28, 2007, at 9:10 AM, Tim Perrett wrote:
> Hey Corbin
>
> Thanks for the reply. Ive been looking at the DragNDropOutlineView
> example, and I found this comment
>
> "On MacOS 10.5 and later, in willDisplayCell: we can dynamically set
> the contextual menu (right click menu) for a particular cell. If
> nothing is set, then the contextual menu for the NSOutlineView
> itself will be used. We will set a different menu for the
> "Expandable?" column, and leave the default one for everything else."
>
> Which Im guessing is what you meant about making it easier in 10.5?
> Isn't that using NSMenu however? rather than a panel which I belie
> those little HUD windows are?
Tim -- you are right. I am talking about NSMenu, but your original
email seems to indicate that is what you wanted:
> What I would like to end up with is on my outline view (that already
> works no problems), when the user right-clicks one of the rows, I
> would like that one to become the selected row, and a context menu
> to popup beside, from which I can set some parameters. I have read
> about the menu outlet, but im not sure if thats the right way to go,
> and even if it is, what it needs to be connected to?
A context menu is a regular menu; not a HUD. I would discourage you
from creating UI that does something other than pop up a context menu
on the right click; it won't be what people expect, and isn't easily
discoverable. Apps that use HUD's typically bring them up in some
other way. For instance, they have a button in the cell to bring it
up, a toolbar item (Aperture), or an item in the context menu itself
(iCal).
If you really want to do a HUD, you will probably have to subclass
NSTableView, override mouseDown:, call super (to do all the work of
tracking and changing the selection), and then show your HUD if it was
a right click.
--corbin -
On 28 Nov 2007, at 18:48, Corbin Dunn wrote:
> Tim -- you are right. I am talking about NSMenu, but your original
> email seems to indicate that is what you wanted:
Fair comment, my initial wording really wasnt that great :)
> A context menu is a regular menu; not a HUD. I would discourage you
> from creating UI that does something other than pop up a context
> menu on the right click; it won't be what people expect, and isn't
> easily discoverable. Apps that use HUD's typically bring them up in
> some other way. For instance, they have a button in the cell to
> bring it up, a toolbar item (Aperture), or an item in the context
> menu itself (iCal).
Sounds like its best to stick to a context menu for the time being.
The obvious one that uses HUD on right click is Interface builder.... :)
Thats why I was thinking of using a HUD rather than a context menu, as
some of the parameters I need to set are not "context menu friendly".
What are your thoughts?
> If you really want to do a HUD, you will probably have to subclass
> NSTableView, override mouseDown:, call super (to do all the work of
> tracking and changing the selection), and then show your HUD if it
> was a right click.
Its actually on a NSOutlineView - is the same applicable?
Cheers
Tim -
>> A context menu is a regular menu; not a HUD. I would discourage you
>> from creating UI that does something other than pop up a context
>> menu on the right click; it won't be what people expect, and isn't
>> easily discoverable. Apps that use HUD's typically bring them up in
>> some other way. For instance, they have a button in the cell to
>> bring it up, a toolbar item (Aperture), or an item in the context
>> menu itself (iCal).
>
> Sounds like its best to stick to a context menu for the time being.
> The obvious one that uses HUD on right click is Interface
> builder.... :)
Ahh yes, IB -- they are the exception to the rule. They have taken
over what "right click" means. Instead of it meaning "context menu",
it means "make a connection". In some ways it is unfortunate, as it
would be nice to right click on a particular item and have some
context menu options (cut/copy/paste, for example).
>
> Thats why I was thinking of using a HUD rather than a context menu,
> as some of the parameters I need to set are not "context menu
> friendly". What are your thoughts?
Well there are several "cool" approaches. You could do something like
iCal when you click on an event, and/or Delicious Library 2 (http://theocacao.com/document.page/505
) -- they both do popout bubbles when clicking on a particular item.
You could do this when clicking on some signifier in a row (for
instance -- a button, or selecting the row itself).
If you want a HUD, it should just be context aware. You could have
some toolbar button that shows/hides the HUD, and it is aware of the
current selection in the tableview and updates itself as the selection
changes. This is a lot more standard than requiring the user to right
click to show it, and makes discoverability easier.
>
>
>> If you really want to do a HUD, you will probably have to subclass
>> NSTableView, override mouseDown:, call super (to do all the work of
>> tracking and changing the selection), and then show your HUD if it
>> was a right click.
>
> Its actually on a NSOutlineView - is the same applicable?
Yup! it is a subclass.
corbin


