You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by "Todd Volkert (JIRA)" <ji...@apache.org> on 2009/07/22 16:09:14 UTC

[jira] Created: (PIVOT-181) Context menu handler

Context menu handler
--------------------

                 Key: PIVOT-181
                 URL: https://issues.apache.org/jira/browse/PIVOT-181
             Project: Pivot
          Issue Type: New Feature
          Components: wtk
            Reporter: Todd Volkert
            Assignee: Todd Volkert
             Fix For: 1.3


Create framework-level support for context menus by creating a Component.ContextMenuHandler interface.  When the display host detects a right click, it will:

1) Get a reference to the lowest-level component that the mouse is over, and if that's non-null...
2) Construct the path from the display to that component, instantiate a MenuPopup
3) Walk the path, passing the menu popup's menu to each ContextMenuHandler that is found along the path
4) Open the menu popup if the menu is non-empty after the path has been walked

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIVOT-181) Context menu handler

Posted by "Todd Volkert (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-181?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12734227#action_12734227 ] 

Todd Volkert commented on PIVOT-181:
------------------------------------

I think the bottom line is that the caller can have the best of all worlds here:

1) If they want to use the feature and have their context menus tied to the component hierarchy over which the mouse button was clicked (I believe this to be a very common use case), then they can.

2) If they want to not use the feature and roll their own context menu sub-system, they can (by not setting any context menu handlers on any components).

3) If they want to go one step further and prevent anyone else in the application from using this feature and colliding with their custom sub-system, they can do that too, by setting a context menu handler on the display that simply returns false.

> Context menu handler
> --------------------
>
>                 Key: PIVOT-181
>                 URL: https://issues.apache.org/jira/browse/PIVOT-181
>             Project: Pivot
>          Issue Type: New Feature
>          Components: wtk
>            Reporter: Todd Volkert
>            Assignee: Todd Volkert
>             Fix For: 1.3
>
>
> Create framework-level support for context menus by creating a Component.ContextMenuHandler interface.  When the display host detects a right click, it will:
> 1) Get a reference to the lowest-level component that the mouse is over, and if that's non-null...
> 2) Construct the path from the display to that component, instantiate a MenuPopup
> 3) Walk the path, passing the menu popup's menu to each ContextMenuHandler that is found along the path
> 4) Open the menu popup if the menu is non-empty after the path has been walked

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIVOT-181) Context menu handler

Posted by "Noel Grandin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-181?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12734215#action_12734215 ] 

Noel Grandin commented on PIVOT-181:
------------------------------------

I'm sure that could work.

But what I'm concerned about is if you mix and match a custom container component from one place with a custom child component from a different place, and the custom container component is looking to add items into a context menu, while the child component is just going to take control of the right-click event and do it's own thing.

Basically, I think we're creating a fragile situation, where custom components are easily going to break each other.

And I don't really see the need - I've never seen any application do this kind of hierarchical accumulation of context-menu items.

Just my thoughts, I'm not vehemently opposed, I just would prefer to minimise potential conflicts of expectations.


> Context menu handler
> --------------------
>
>                 Key: PIVOT-181
>                 URL: https://issues.apache.org/jira/browse/PIVOT-181
>             Project: Pivot
>          Issue Type: New Feature
>          Components: wtk
>            Reporter: Todd Volkert
>            Assignee: Todd Volkert
>             Fix For: 1.3
>
>
> Create framework-level support for context menus by creating a Component.ContextMenuHandler interface.  When the display host detects a right click, it will:
> 1) Get a reference to the lowest-level component that the mouse is over, and if that's non-null...
> 2) Construct the path from the display to that component, instantiate a MenuPopup
> 3) Walk the path, passing the menu popup's menu to each ContextMenuHandler that is found along the path
> 4) Open the menu popup if the menu is non-empty after the path has been walked

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIVOT-181) Context menu handler

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-181?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12734220#action_12734220 ] 

Greg Brown commented on PIVOT-181:
----------------------------------

>But what I'm concerned about is if you mix and match a custom container component from one place with a 
>custom child component from a different place, and the custom container component is looking to add items
>into a context menu, while the child component is just going to take control of the right-click event and do it's 
>own thing. 

That's exactly what we'd like to support. The lowest-level child component *should* have the ability to override the behavior of the context menu. In many or most cases, it won't need or want to, but the option should be there.

>And I don't really see the need - I've never seen any application do this kind of hierarchical accumulation of 
>context-menu items. 

Todd currently has a pretty solid use case, and after talking it through, I think other applications could easily benefit from it as well. Given that the "context" of any given component is its container ancestry, this provides a pretty powerful way for any component/container in the context to hook into the menuing system.


> Context menu handler
> --------------------
>
>                 Key: PIVOT-181
>                 URL: https://issues.apache.org/jira/browse/PIVOT-181
>             Project: Pivot
>          Issue Type: New Feature
>          Components: wtk
>            Reporter: Todd Volkert
>            Assignee: Todd Volkert
>             Fix For: 1.3
>
>
> Create framework-level support for context menus by creating a Component.ContextMenuHandler interface.  When the display host detects a right click, it will:
> 1) Get a reference to the lowest-level component that the mouse is over, and if that's non-null...
> 2) Construct the path from the display to that component, instantiate a MenuPopup
> 3) Walk the path, passing the menu popup's menu to each ContextMenuHandler that is found along the path
> 4) Open the menu popup if the menu is non-empty after the path has been walked

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIVOT-181) Context menu handler

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-181?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12734287#action_12734287 ] 

Greg Brown commented on PIVOT-181:
----------------------------------

I have added a name property to both Menu.Section and Menu.Item.


> Context menu handler
> --------------------
>
>                 Key: PIVOT-181
>                 URL: https://issues.apache.org/jira/browse/PIVOT-181
>             Project: Pivot
>          Issue Type: New Feature
>          Components: wtk
>            Reporter: Todd Volkert
>            Assignee: Todd Volkert
>             Fix For: 1.3
>
>
> Create framework-level support for context menus by creating a Component.ContextMenuHandler interface.  When the display host detects a right click, it will:
> 1) Get a reference to the lowest-level component that the mouse is over, and if that's non-null...
> 2) Construct the path from the display to that component, instantiate a MenuPopup
> 3) Walk the path, passing the menu popup's menu to each ContextMenuHandler that is found along the path
> 4) Open the menu popup if the menu is non-empty after the path has been walked

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIVOT-181) Context menu handler

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-181?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12734153#action_12734153 ] 

Greg Brown commented on PIVOT-181:
----------------------------------

I don't think this approach will preclude custom context menu handling. You don't have to attach any context menu handlers to your components - you can simply choose to process the mouse events yourself (the same applies to drag sources and drop targets). Also, a handler can clear the menu if it wants to prevent it from being shown. However, we may want to add a boolean return value to the "configureContextMenu()" method, or whatever it is called, such that handlers can stop propagation down the path.



> Context menu handler
> --------------------
>
>                 Key: PIVOT-181
>                 URL: https://issues.apache.org/jira/browse/PIVOT-181
>             Project: Pivot
>          Issue Type: New Feature
>          Components: wtk
>            Reporter: Todd Volkert
>            Assignee: Todd Volkert
>             Fix For: 1.3
>
>
> Create framework-level support for context menus by creating a Component.ContextMenuHandler interface.  When the display host detects a right click, it will:
> 1) Get a reference to the lowest-level component that the mouse is over, and if that's non-null...
> 2) Construct the path from the display to that component, instantiate a MenuPopup
> 3) Walk the path, passing the menu popup's menu to each ContextMenuHandler that is found along the path
> 4) Open the menu popup if the menu is non-empty after the path has been walked

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIVOT-181) Context menu handler

Posted by "Noel Grandin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-181?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12734133#action_12734133 ] 

Noel Grandin commented on PIVOT-181:
------------------------------------

I'm not sure that context-menu handling is sufficiently standardized that you can do ALL of that. (I'm in general agreement with need for some framework level support).

Specifically, I don't think you can walk down the tree and accumulate context menu entries, because some components are going to want to do radically different things on right-mouse-click.
For example, some people might want to implement radial context menus, or simply do something else altogether on right-mouse-click.

But I can definitely see the need for some utility code that makes implementing context menus easier.


> Context menu handler
> --------------------
>
>                 Key: PIVOT-181
>                 URL: https://issues.apache.org/jira/browse/PIVOT-181
>             Project: Pivot
>          Issue Type: New Feature
>          Components: wtk
>            Reporter: Todd Volkert
>            Assignee: Todd Volkert
>             Fix For: 1.3
>
>
> Create framework-level support for context menus by creating a Component.ContextMenuHandler interface.  When the display host detects a right click, it will:
> 1) Get a reference to the lowest-level component that the mouse is over, and if that's non-null...
> 2) Construct the path from the display to that component, instantiate a MenuPopup
> 3) Walk the path, passing the menu popup's menu to each ContextMenuHandler that is found along the path
> 4) Open the menu popup if the menu is non-empty after the path has been walked

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (PIVOT-181) Context menu handler

Posted by "Todd Volkert (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-181?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Todd Volkert resolved PIVOT-181.
--------------------------------

    Resolution: Fixed

This is done.  There is now a org.apache.pivot.wtk.MenuHandler interface, with a configureContextMenu(Component component, Menu menu, int x, int y) method.  You can set a MenuHandler on any component.

Note that there are also configureMenuBar(Component component, MenuBar menuBar) and cleanupMenuBar(Component component, MenuBar menuBar) methods in that interface.  These are not called into yet by anyone but are in the interface for future expansion.  They will be utilized in a future release.

> Context menu handler
> --------------------
>
>                 Key: PIVOT-181
>                 URL: https://issues.apache.org/jira/browse/PIVOT-181
>             Project: Pivot
>          Issue Type: New Feature
>          Components: wtk
>            Reporter: Todd Volkert
>            Assignee: Todd Volkert
>             Fix For: 1.3
>
>
> Create framework-level support for context menus by creating a Component.ContextMenuHandler interface.  When the display host detects a right click, it will:
> 1) Get a reference to the lowest-level component that the mouse is over, and if that's non-null...
> 2) Construct the path from the display to that component, instantiate a MenuPopup
> 3) Walk the path, passing the menu popup's menu to each ContextMenuHandler that is found along the path
> 4) Open the menu popup if the menu is non-empty after the path has been walked

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIVOT-181) Context menu handler

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-181?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12734251#action_12734251 ] 

Greg Brown commented on PIVOT-181:
----------------------------------

We'll probably want to add a name property to Menu.Section and a getSection(String) method to Menu so context menu handlers can get references to the sections they are interested in. We'll need to add a sectionNameChanged() event to MenuListener as well.



> Context menu handler
> --------------------
>
>                 Key: PIVOT-181
>                 URL: https://issues.apache.org/jira/browse/PIVOT-181
>             Project: Pivot
>          Issue Type: New Feature
>          Components: wtk
>            Reporter: Todd Volkert
>            Assignee: Todd Volkert
>             Fix For: 1.3
>
>
> Create framework-level support for context menus by creating a Component.ContextMenuHandler interface.  When the display host detects a right click, it will:
> 1) Get a reference to the lowest-level component that the mouse is over, and if that's non-null...
> 2) Construct the path from the display to that component, instantiate a MenuPopup
> 3) Walk the path, passing the menu popup's menu to each ContextMenuHandler that is found along the path
> 4) Open the menu popup if the menu is non-empty after the path has been walked

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.