| author | Mihai Sucan | 2011-06-03 15:37:44 (EDT) |
|---|---|---|
| committer | Felipe Heidrich | 2011-06-03 15:37:44 (EDT) |
| commit | b3ccb0ce770f03a5dbca3da7116c217003ff8ce1 (patch) (side-by-side diff) | |
| tree | 5c001180859435aedbb09448e0a346e9802e7d30 | |
| parent | 7729af9985103d4ce82e8f324c2ecf3417850c8b (diff) | |
| download | org.eclipse.orion.client-b3ccb0ce770f03a5dbca3da7116c217003ff8ce1.zip org.eclipse.orion.client-b3ccb0ce770f03a5dbca3da7116c217003ff8ce1.tar.gz org.eclipse.orion.client-b3ccb0ce770f03a5dbca3da7116c217003ff8ce1.tar.bz2 | |
Bug 334583 - [client][editor]API: provide support for custom context menu
| -rw-r--r-- | bundles/org.eclipse.orion.client.editor/web/orion/textview/textView.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/bundles/org.eclipse.orion.client.editor/web/orion/textview/textView.js b/bundles/org.eclipse.orion.client.editor/web/orion/textview/textView.js index 5b4365a..05bcba1 100644 --- a/bundles/org.eclipse.orion.client.editor/web/orion/textview/textView.js +++ b/bundles/org.eclipse.orion.client.editor/web/orion/textview/textView.js @@ -8,6 +8,7 @@ * Contributors: * Felipe Heidrich (IBM Corporation) - initial API and implementation * Silenio Quarti (IBM Corporation) - initial API and implementation + * Mihai Sucan (Mozilla Foundation) - fix for Bug 334583 ******************************************************************************/ /*global window document navigator setTimeout clearTimeout alert XMLHttpRequest */ @@ -882,6 +883,30 @@ orion.textview.TextView = (function() { } return false; }, + /** + * @class This is the event sent when the user right clicks or otherwise invokes the context menu of the view. + * <p> + * <b>See:</b><br/> + * {@link orion.textview.TextView}<br/> + * {@link orion.textview.TextView#event:onContextMenu} + * </p> + * + * @name orion.textview.ContextMenuEvent + * + * @property {Number} x The pointer location on the x axis, relative to the document the user is editing. + * @property {Number} y The pointer location on the y axis, relative to the document the user is editing. + * @property {Number} screenX The pointer location on the x axis, relative to the screen. This is copied from the DOM contextmenu event.screenX property. + * @property {Number} screenY The pointer location on the y axis, relative to the screen. This is copied from the DOM contextmenu event.screenY property. + */ + /** + * This event is sent when the user invokes the view context menu. + * + * @event + * @param {orion.textview.ContextMenuEvent} contextMenuEvent the event + */ + onContextMenu: function(contextMenuEvent) { + this._eventTable.sendEvent("ContextMenu", contextMenuEvent); + }, /** * @class This is the event sent when the text view is destroyed. * <p> @@ -1531,6 +1556,12 @@ orion.textview.TextView = (function() { }, _handleContextMenu: function (e) { if (!e) { e = window.event; } + var scroll = this._getScroll(); + var viewRect = this._viewDiv.getBoundingClientRect(); + var viewPad = this._getViewPadding(); + var x = e.clientX + scroll.x - viewRect.left - viewPad.left; + var y = e.clientY + scroll.y - viewRect.top - viewPad.top; + this.onContextMenu({x: x, y: y, screenX: e.screenX, screenY: e.screenY}); if (e.preventDefault) { e.preventDefault(); } return false; }, |

