You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by lello <rb...@gmail.com> on 2011/04/26 16:02:25 UTC
Disable Menu.Item
Hi all,
I am trying to have context menu with several menu items, some of which
should be disabled (still showing but grayed) or enabled according to where
the context menu is opened. I couldn't find a way to disable an item. Is is
possible?
Also, is it possible to trigger a context menu on a tableView when a
TableViewRowEditor is open?
Thanks
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2865710.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Disable Menu.Item
Posted by Sandro Martini <sa...@gmail.com>.
Hi all,
just committed the first part of the fix, the remaining part in next days.
Tell me what to do on the Contextual menu (as written in the ticket) ...
Bye,
Sandro
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2891641.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Disable Menu.Item
Posted by Sandro Martini <sa...@gmail.com>.
Ciao Raffaele,
I've just seen the ticket: https://issues.apache.org/jira/browse/PIVOT-737
thank you very much, as soon as possible I'll try to look at it (or Greg ...
the first who have some time :-) ).
Have a good day,
Sandro
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2873750.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Disable Menu.Item
Posted by Sandro Martini <sa...@gmail.com>.
Hi,
if you have some time, you are welcome to do it :-) ...
And if you can, please attach even a small test case (and if you have maybe
even a patch like yours), only remember to add it to the 2.0.1 release as
fix, and select the "Grant for inclusion in ASF work" on any attach.
Uh, important, in the comment of the ticket, please can you add the url of
the full discussion thread here on Nabble) ?
If you want, assign me or Greg to the ticket so as soon as possible we'll
look at it.
And last, post here the link to the issue, just to have all data ...
Thank you very much,
Sandro
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2870238.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Disable Menu.Item
Posted by lello <rb...@gmail.com>.
Shall I create one?
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2870220.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Disable Menu.Item
Posted by Greg Brown <gk...@verizon.net>.
It's a bug, so a JIRA ticket would be appropriate.
On Apr 27, 2011, at 6:37 AM, Sandro Martini wrote:
> Hi all,
> excuse me, just to close the point ... is needed a jira ticket for this fr
> the 2.0.1 ?
> And on the behavior of TerraTableViewSkin with row editor and mouse clicks,
> or even on Menu.Items ?
>
> Bye
>
>
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2869900.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Disable Menu.Item
Posted by Sandro Martini <sa...@gmail.com>.
Hi all,
excuse me, just to close the point ... is needed a jira ticket for this fr
the 2.0.1 ?
And on the behavior of TerraTableViewSkin with row editor and mouse clicks,
or even on Menu.Items ?
Bye
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2869900.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Disable Menu.Item
Posted by lello <rb...@gmail.com>.
Thanks,
I updated the TerraTableViewSkin to listen only to the left mouse button.
Just FYI you need to update both mouseClick() and mouseDown().
Indeed mouseDown() triggers a selection with both mouse button. In my case
the selection starts a new
rowEditor so I had to change mouseDown() to repond to left click only.
Greg Brown-2 wrote:
>
> The problem is that TerraTableViewSkin initiates the edit in mouseClick()
> without regard for which button was pressed. That should probably be fixed
> to only initiate the edit on left-click (same for ListView and TreeView).
>
> Are you able to build from source? If so, could you try making this change
> and see if it resolves your problem?
>
> On Apr 26, 2011, at 2:40 PM, lello wrote:
>
>> The problem with this point is that the roweditor shows up with a click
>> on
>> the right button of the mouse,
>> and I'd like it to respond only to the left button. What method shall I
>> overwrite to do that?
>>
>>
>> Greg Brown-2 wrote:
>>>
>>>> Also, is it possible to trigger a context menu on a tableView when a
>>>> TableViewRowEditor is open?
>>>
>>> It is, but opening a menu and row editor simultaneously may not produce
>>> the best user experience unless you make the row editor window the
>>> menu's
>>> owner.
>>>
>>
>>
>>
>> --
>> View this message in context:
>> http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2866833.html
>> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2866973.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Disable Menu.Item
Posted by Greg Brown <gk...@verizon.net>.
The problem is that TerraTableViewSkin initiates the edit in mouseClick() without regard for which button was pressed. That should probably be fixed to only initiate the edit on left-click (same for ListView and TreeView).
Are you able to build from source? If so, could you try making this change and see if it resolves your problem?
On Apr 26, 2011, at 2:40 PM, lello wrote:
> The problem with this point is that the roweditor shows up with a click on
> the right button of the mouse,
> and I'd like it to respond only to the left button. What method shall I
> overwrite to do that?
>
>
> Greg Brown-2 wrote:
>>
>>> Also, is it possible to trigger a context menu on a tableView when a
>>> TableViewRowEditor is open?
>>
>> It is, but opening a menu and row editor simultaneously may not produce
>> the best user experience unless you make the row editor window the menu's
>> owner.
>>
>
>
>
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2866833.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Disable Menu.Item
Posted by lello <rb...@gmail.com>.
The problem with this point is that the roweditor shows up with a click on
the right button of the mouse,
and I'd like it to respond only to the left button. What method shall I
overwrite to do that?
Greg Brown-2 wrote:
>
>> Also, is it possible to trigger a context menu on a tableView when a
>> TableViewRowEditor is open?
>
> It is, but opening a menu and row editor simultaneously may not produce
> the best user experience unless you make the row editor window the menu's
> owner.
>
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2866833.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Disable Menu.Item
Posted by lello <rb...@gmail.com>.
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2866062.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Disable Menu.Item
Posted by Greg Brown <gk...@verizon.net>.
Ah. If you are using an Action, you can just disable the action.
On Apr 26, 2011, at 2:31 PM, lello wrote:
> In the meanwhile I found the problem.
> If the action is removed then setEnabled(false) warks as it should.
> Apparently you must have a null action,
> or the menu item is forced to be enabled. Is this true?
>
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2866794.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Disable Menu.Item
Posted by lello <rb...@gmail.com>.
In the meanwhile I found the problem.
If the action is removed then setEnabled(false) warks as it should.
Apparently you must have a null action,
or the menu item is forced to be enabled. Is this true?
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2866794.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Disable Menu.Item
Posted by lello <rb...@gmail.com>.
The example is very easy.
You can use the context-menu example provided by pivot tutorial.
I just added the line of code:
whatIsThisMenuItem.setEnabled(false);
to the file ContextMenu.java (at line 40).
The context menu is still visible and working.
Can you reproduce it?
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2866755.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Disable Menu.Item
Posted by lello <rb...@gmail.com>.
Sorry,
I'll try to write something asap.
Greg Brown-2 wrote:
>
> I meant a working example that I can run. Thanks.
>
> On Apr 26, 2011, at 11:25 AM, lello wrote:
>
>> Sure,
>>
>> the code should be something like this:
>>
>>
>> private MenuHandler treeMenuHandler = new MenuHandler.Adapter() {
>>
>> @Override
>> public boolean configureContextMenu(Component cmpnt, Menu menu,
>> int
>> x, int y) {
>>
>> TreeView tv = (TreeView) cmpnt;
>> final Tree.Path groupNodePath = tv.getNodeAt(y);
>> final int treeIndex = tv.getRowIndex(groupNodePath);
>>
>> // Create the context menu
>> Menu.Section menuSection1 = new Menu.Section();
>> Menu.Section menuSection2 = new Menu.Section();
>> Menu.Item newCollectionMenuItem = new Menu.Item("New
>> collection");
>> Menu.Item renameCollectionMenuItem = new Menu.Item("Rename
>> collection");
>> Menu.Item removeCollectionMenuItem = new Menu.Item("Remove
>> collection");
>>
>> if (treeIndex == 0) {
>> menuSection1.add(newCollectionMenuItem);
>> renameCollectionMenuItem.setEnabled(false);
>> removeCollectionMenuItem.setEnabled(false);
>> menuSection2.add(renameCollectionMenuItem);
>> menuSection2.add(removeCollectionMenuItem);
>> }
>>
>> menu.getSections().add(menuSection1);
>> menu.getSections().add(menuSection2);
>>
>> return false;
>> }
>> };
>>
>>
>> --
>> View this message in context:
>> http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2865996.html
>> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2866066.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Disable Menu.Item
Posted by Greg Brown <gk...@verizon.net>.
I meant a working example that I can run. Thanks.
On Apr 26, 2011, at 11:25 AM, lello wrote:
> Sure,
>
> the code should be something like this:
>
>
> private MenuHandler treeMenuHandler = new MenuHandler.Adapter() {
>
> @Override
> public boolean configureContextMenu(Component cmpnt, Menu menu, int
> x, int y) {
>
> TreeView tv = (TreeView) cmpnt;
> final Tree.Path groupNodePath = tv.getNodeAt(y);
> final int treeIndex = tv.getRowIndex(groupNodePath);
>
> // Create the context menu
> Menu.Section menuSection1 = new Menu.Section();
> Menu.Section menuSection2 = new Menu.Section();
> Menu.Item newCollectionMenuItem = new Menu.Item("New
> collection");
> Menu.Item renameCollectionMenuItem = new Menu.Item("Rename
> collection");
> Menu.Item removeCollectionMenuItem = new Menu.Item("Remove
> collection");
>
> if (treeIndex == 0) {
> menuSection1.add(newCollectionMenuItem);
> renameCollectionMenuItem.setEnabled(false);
> removeCollectionMenuItem.setEnabled(false);
> menuSection2.add(renameCollectionMenuItem);
> menuSection2.add(removeCollectionMenuItem);
> }
>
> menu.getSections().add(menuSection1);
> menu.getSections().add(menuSection2);
>
> return false;
> }
> };
>
>
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2865996.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Disable Menu.Item
Posted by lello <rb...@gmail.com>.
Sure,
the code should be something like this:
private MenuHandler treeMenuHandler = new MenuHandler.Adapter() {
@Override
public boolean configureContextMenu(Component cmpnt, Menu menu, int
x, int y) {
TreeView tv = (TreeView) cmpnt;
final Tree.Path groupNodePath = tv.getNodeAt(y);
final int treeIndex = tv.getRowIndex(groupNodePath);
// Create the context menu
Menu.Section menuSection1 = new Menu.Section();
Menu.Section menuSection2 = new Menu.Section();
Menu.Item newCollectionMenuItem = new Menu.Item("New
collection");
Menu.Item renameCollectionMenuItem = new Menu.Item("Rename
collection");
Menu.Item removeCollectionMenuItem = new Menu.Item("Remove
collection");
if (treeIndex == 0) {
menuSection1.add(newCollectionMenuItem);
renameCollectionMenuItem.setEnabled(false);
removeCollectionMenuItem.setEnabled(false);
menuSection2.add(renameCollectionMenuItem);
menuSection2.add(removeCollectionMenuItem);
}
menu.getSections().add(menuSection1);
menu.getSections().add(menuSection2);
return false;
}
};
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2865996.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Disable Menu.Item
Posted by Greg Brown <gk...@verizon.net>.
BXML is just a shortcut to doing something programmatically, so the behavior should be the same either way.
setEnabled(false) should definitely work. Can you share a code sample that demonstrates the problem?
On Apr 26, 2011, at 11:17 AM, lello wrote:
> I tried setEnabled(false) but it doesn't work.
> The menu item is not affected. I am doing this not using bxml but
> programmatically.
>
>
> Greg Brown-2 wrote:
>>
>>> I am trying to have context menu with several menu items, some of which
>>> should be disabled (still showing but grayed) or enabled according to
>>> where
>>> the context menu is opened. I couldn't find a way to disable an item. Is
>>> is
>>> possible?
>>
>> You can call setEnabled(false) on the menu item.
>>
>>> Also, is it possible to trigger a context menu on a tableView when a
>>> TableViewRowEditor is open?
>>
>> It is, but opening a menu and row editor simultaneously may not produce
>> the best user experience unless you make the row editor window the menu's
>> owner.
>>
>
>
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2865959.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Disable Menu.Item
Posted by lello <rb...@gmail.com>.
I tried setEnabled(false) but it doesn't work.
The menu item is not affected. I am doing this not using bxml but
programmatically.
Greg Brown-2 wrote:
>
>> I am trying to have context menu with several menu items, some of which
>> should be disabled (still showing but grayed) or enabled according to
>> where
>> the context menu is opened. I couldn't find a way to disable an item. Is
>> is
>> possible?
>
> You can call setEnabled(false) on the menu item.
>
>> Also, is it possible to trigger a context menu on a tableView when a
>> TableViewRowEditor is open?
>
> It is, but opening a menu and row editor simultaneously may not produce
> the best user experience unless you make the row editor window the menu's
> owner.
>
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Disable-Menu-Item-tp2865710p2865959.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: Disable Menu.Item
Posted by Greg Brown <gk...@verizon.net>.
> I am trying to have context menu with several menu items, some of which
> should be disabled (still showing but grayed) or enabled according to where
> the context menu is opened. I couldn't find a way to disable an item. Is is
> possible?
You can call setEnabled(false) on the menu item.
> Also, is it possible to trigger a context menu on a tableView when a
> TableViewRowEditor is open?
It is, but opening a menu and row editor simultaneously may not produce the best user experience unless you make the row editor window the menu's owner.