Opened 11 years ago
Closed 5 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 11 years ago by
comment:2 Changed 11 years ago by
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 11 years ago by
Milestone: | tbd → 1.5 |
---|
comment:4 Changed 11 years ago by
Milestone: | 1.5 → 1.6 |
---|
comment:5 Changed 10 years ago by
Milestone: | 1.6 → future |
---|
comment:6 Changed 8 years ago by
Summary: | dijit.Menu needs to be able to determine if an item or subitem was clicked _before_ onClose → Menu: need to be able to determine if an item or subitem was clicked _before_ onClose |
---|
comment:7 Changed 8 years ago by
Priority: | high → low |
---|
comment:8 Changed 5 years ago by
Milestone: | future → 1.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 5 years ago by
Resolution: | → patchwelcome |
---|---|
Status: | new → closed |
I think I understand the reason you want it. Menu.onCancel() doesn't work for you? (And Menu.onExecute() is for the opposite case.)