Opened 10 years ago

Closed 4 years ago

#9889 closed enhancement (patchwelcome)

Menu: need to be able to determine if an item or subitem was clicked _before_ onClose

Reported by: Phil DeJarnett Owned by:
Priority: low Milestone: 1.13
Component: Dijit Version: 1.3.2
Keywords: dijit.Menu Cc:
Blocked By: Blocking:

Description

I want to be able to listen to a dijit.Menu and determine if it was closed by canceling vs if it was closed by an item or subitem being clicked.

Currently, by replacing onItemClick, I can detect when a direct descendant is clicked before the menu is closed. However, if a child item is clicked, the menu gets closed before the action is processed.

The reason for this feature: I have a right-click menu on a grid. If some items are selected, and the user right-clicks on them, nothing changes. If they right-click on a different item, the current selection is stored, and the item is selected.

Now, if the user cancels the menu (say, they mis-clicked on the items), I restore the original selection. However, if they click on anything in the menu, I retain the new selection, and delete the old one. Then my action(s) can use the same code to see which items are selected, whether they are from the popup or not.

My current solution is to have a 100ms timeout on the onClose event, in case a subitem was clicked. It works, but I worry, since it may still happen at the wrong time on slower systems.

What would be even more preferable would to instead ensure that the menu command - no matter how deep - is processed first, before the menu is closed. Then I could bypass all of the round-about way to get what I really want, which is to know that an Item was clicked vs being canceled.

Change History (9)

comment:1 Changed 10 years ago by bill

I think I understand the reason you want it. Menu.onCancel() doesn't work for you? (And Menu.onExecute() is for the opposite case.)

comment:2 Changed 10 years ago by Phil DeJarnett

I tried both onCancel and onExecute. They don't fire consistently between top-level menu items and sub menu items.

I'm pretty sure that onCancel never got called when I tried it, and onExecute only gets called if a top-level item was clicked, but never for sub items.

Really, in thinking it through, that is the overriding issue. If you attach to the context menu, you can't get notified of a sub item being clicked until after the menu is already closed.

comment:3 Changed 10 years ago by bill

Milestone: tbd1.5

comment:4 Changed 9 years ago by Adam Peller

Milestone: 1.51.6

comment:5 Changed 9 years ago by bill

Milestone: 1.6future

comment:6 Changed 7 years ago by bill

Summary: dijit.Menu needs to be able to determine if an item or subitem was clicked _before_ onCloseMenu: need to be able to determine if an item or subitem was clicked _before_ onClose

comment:7 Changed 7 years ago by bill

Priority: highlow

comment:8 Changed 4 years ago by dylan

Milestone: future1.12

Given that no one has shown interest in creating a patch in the past 5+ years, I'm closing this as patchwelcome.

comment:9 Changed 4 years ago by dylan

Resolution: patchwelcome
Status: newclosed
Note: See TracTickets for help on using tickets.