@phosphor/application
Advanced tools
Comparing version 0.3.0 to 0.3.1
import { CommandRegistry } from '@phosphor/commands'; | ||
import { Token } from '@phosphor/coreutils'; | ||
import { Widget } from '@phosphor/widgets'; | ||
import { ContextMenu, Menu, Widget } from '@phosphor/widgets'; | ||
/** | ||
@@ -106,2 +106,6 @@ * A user-defined application plugin. | ||
/** | ||
* The application context menu. | ||
*/ | ||
readonly contextMenu: ContextMenu; | ||
/** | ||
* The application shell widget. | ||
@@ -273,2 +277,16 @@ * | ||
/** | ||
* A method invoked on a document `'contextmenu'` event. | ||
* | ||
* #### Notes | ||
* The default implementation of this method opens the application | ||
* `contextMenu` at the current mouse position. | ||
* | ||
* If the application context menu has no matching content *or* if | ||
* the shift key is pressed, the default browser context menu will | ||
* be opened instead. | ||
* | ||
* A subclass may reimplement this method as needed. | ||
*/ | ||
protected evtContextMenu(event: MouseEvent): void; | ||
/** | ||
* A method invoked on a window `'resize'` event. | ||
@@ -303,2 +321,6 @@ * | ||
shell: T; | ||
/** | ||
* A custom renderer for the context menu. | ||
*/ | ||
contextMenuRenderer?: Menu.IRenderer; | ||
} | ||
@@ -305,0 +327,0 @@ /** |
@@ -28,6 +28,2 @@ "use strict"; | ||
function Application(options) { | ||
/** | ||
* The application command registry. | ||
*/ | ||
this.commands = new commands_1.CommandRegistry(); | ||
this._started = false; | ||
@@ -37,2 +33,10 @@ this._pluginMap = Private.createPluginMap(); | ||
this._delegate = new coreutils_1.PromiseDelegate(); | ||
// Create the application command registry. | ||
var commands = new commands_1.CommandRegistry(); | ||
// Create the application context menu. | ||
var renderer = options.contextMenuRenderer; | ||
var contextMenu = new widgets_1.ContextMenu({ commands: commands, renderer: renderer }); | ||
// Initialize the application state. | ||
this.commands = commands; | ||
this.contextMenu = contextMenu; | ||
this.shell = options.shell; | ||
@@ -296,2 +300,5 @@ } | ||
break; | ||
case 'contextmenu': | ||
this.evtContextMenu(event); | ||
break; | ||
} | ||
@@ -322,2 +329,3 @@ }; | ||
Application.prototype.addEventListeners = function () { | ||
document.addEventListener('contextmenu', this); | ||
document.addEventListener('keydown', this, true); | ||
@@ -339,2 +347,24 @@ window.addEventListener('resize', this); | ||
/** | ||
* A method invoked on a document `'contextmenu'` event. | ||
* | ||
* #### Notes | ||
* The default implementation of this method opens the application | ||
* `contextMenu` at the current mouse position. | ||
* | ||
* If the application context menu has no matching content *or* if | ||
* the shift key is pressed, the default browser context menu will | ||
* be opened instead. | ||
* | ||
* A subclass may reimplement this method as needed. | ||
*/ | ||
Application.prototype.evtContextMenu = function (event) { | ||
if (event.shiftKey) { | ||
return; | ||
} | ||
if (this.contextMenu.open(event)) { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
} | ||
}; | ||
/** | ||
* A method invoked on a window `'resize'` event. | ||
@@ -341,0 +371,0 @@ * |
{ | ||
"name": "@phosphor/application", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "PhosphorJS - Pluggable Application", | ||
@@ -17,3 +17,3 @@ "main": "lib/index.js", | ||
"@phosphor/coreutils": "^0.1.5", | ||
"@phosphor/widgets": "^0.3.0" | ||
"@phosphor/widgets": "^0.3.1" | ||
}, | ||
@@ -20,0 +20,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31287
831
Updated@phosphor/widgets@^0.3.1