Open
Bug 87536
Opened 24 years ago
Updated 3 years ago
RFE: alternative to oncontextmenu event
Categories
(Core :: XUL, enhancement)
Tracking
()
REOPENED
Future
People
(Reporter: mail, Unassigned)
Details
RFE
A simple API to add and remove custom items of the context menu.
There has been much discussion over whether authors should be allowed to disable
a contextmenu on right click in order to add their own custom menu.
An alternative solution would be to allow authors to add their own items to the
menu. An interface available through JavaScript could work something like this:
Interface ContextMenu
Attributes
name of type string
length of type integer returns the number of custome menu items added
maximumLength of type integer represents the maximum number of menu items that
may be added
Methods
addMenuItem()
Return Value: index of type integer representing the index in the context menu
Exceptions
INDEX_SIZE_ERR: Raised if the maximum number of custom menu item additions has
been exceeded
removeMenuItem(index)
if index is not specified, the last menu item is removed.
Exceptions
NOT_FOUND_ERR: Raised if the maximum number of custom menu item additions has
been exceeded
addEventListener("command",listener,false)
where only one type of event, command, is supported. command is typically a
click. false is for capture since event capturing is not well-defined here.
This is very rough, but I thought it would be better to post this now than
continue to delay until I have more time to think about the exact details of the
interface. For example, should the constructor include the name and the listener?
Comments?
Comment 1•24 years ago
|
||
Should go to context menu owner.
Assignee: joki → pinkerton
Component: DOM Events → XP Toolkit/Widgets: Menus
QA Contact: vladimire → jrgm
Updated•24 years ago
|
Status: NEW → ASSIGNED
Target Milestone: --- → Future
Comment 2•24 years ago
|
||
Mozilla has oncontextmenu event now.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Reporter | ||
Comment 3•24 years ago
|
||
This was not requesting an oncontextmenu event... but an RFE for ading items to
the standard context menu.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Reporter | ||
Comment 4•24 years ago
|
||
Adobe's SVG Viewer 3.0 added a similar idea for their context menu... see
http://www.protocol7.com/svg-wiki/default.asp?CustomizingContextMenu for
details. I think it would make a good start. I know this won't be thought
about until post 1.0.
Comment 5•23 years ago
|
||
Hm. I was working on something mildly similar to this last night. I figured
out how in DOM to access the context menu of a textbox specifically for
prepending and appending items to a context menu, and how to override the
textbox's default context menu entirely.
Basically, I organized it so the script detects for two attributes,
contextPrepend and contextAppend. These attributes would be space-separated id
values for <popup /> elements.
// code hack for modifying default textbox context menu
function InsertTextboxContextMenus(textbox) {
var hbox = document.getAnonymousNodes(textbox)[0];
var contextId = hbox.getAttribute("context")
if (contextId == "_child") {
var menupopup = document.getAnonymousNodes(hbox)[1];
} else {
menupopup = document.getElementById(contextId);
}
var response = menupopup.cloneNode(true);
var prepend = textbox.getAttribute("contextPrepend").split(/\s+/);
var menuFirstChild = response.childNodes[0]
for (var j = 0; j < prepend.length; j++) {
var prependMenu = document.getElementById(prepend[j]);
if (prependMenu) {
for (var i = 0; i < prependMenu.childNodes.length; i++) {
response.insertBefore(prependMenu.childNodes[i].cloneNode(true),
menuFirstChild);
}
}
}
var append = textbox.getAttribute("contextAppend").split(/\s+/);
for (j = 0; j < append.length; j++) {
var appendMenu = document.getElementById(append[j]);
if (appendMenu) {
for (i = 0; i < appendMenu.childNodes.length; i++) {
response.appendChild(appendMenu.childNodes[i].cloneNode(true));
}
}
}
// make it unique and reset the context to the new menu.
response.id += Math.random().toString().substr(2);
menupopup.parentNode.appendChild(response)
hbox.setAttribute("context", response.id);
}
On one level it works (I also had a function, overrideTextboxContextMenu, that
would forcibly redirect the textbox's anonymous hbox node to have the parent
textbox's context attribute). But when I tried to use it in DOM Inspector code
I was editing, (bug 112922) I received an unusual exception:
Error: controller has no properties
Source File: chrome://global/content/bindings/textbox.xml#input-box.doCommand()
Line: 3
The file in question doesn't include a doCommand() method... and DOM Inspector does.
My two cents -- don't know if they help here.
Component: XP Toolkit/Widgets: Menus → XUL
QA Contact: jrgmorrison → xptoolkit.widgets
Comment 6•12 years ago
|
||
This should probably be closed, as Firefox supports HTML5’s context menus now.
For an example http://davidwalsh.name/html5-context-menu
Comment 7•3 years ago
|
||
The bug assignee is inactive on Bugzilla, so the assignee is being reset.
Assignee: mikepinkerton → nobody
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•