partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

Ext.input.CharContextMenu.js (1015B)


      1 /**
      2  * Overrides Ext.form.field.Text so that it provides a context menu with a character picker.
      3  */
      4 Ext.override(Ext.form.field.Text, {
      5 	initComponent: function () {
      6 		this.callOverridden(arguments);
      7 
      8 		// Create the char selector
      9 		this.charSelector = Ext.create("PartKeepr.ContextMenu.CharPicker", {
     10     		listeners: {
     11     			select: function (a,chr) {
     12     				this.setValue(this.getValue() + chr);
     13     			},
     14     			scope: this
     15     		}
     16     	});
     17 		
     18 		// Create the context menu
     19 		this.menu = Ext.create('widget.menu', {
     20             items: [
     21                 {
     22                 	text: i18n("Insert special character"),
     23                 	menu: this.charSelector
     24                 }
     25                 ]
     26         });
     27 	},
     28 	// Injects the event to the inputEl
     29 	onRender: function () {
     30 		this.callOverridden(arguments);
     31 		
     32 		this.inputEl.on("contextmenu", this.onItemContextMenu, this);
     33 	},
     34 	// Display the context menu
     35 	onItemContextMenu: function (event, el) {
     36 		event.stopEvent();
     37 	    this.menu.showAt(event.getXY());
     38 	}
     39 });