1
0
فهرست منبع

Toggle panels commands menu on right click

Mariano Montone 3 سال پیش
والد
کامیت
8fbec3d5f7
2فایلهای تغییر یافته به همراه60 افزوده شده و 14 حذف شده
  1. 43 8
      src/Helios-Core.js
  2. 17 6
      src/Helios-Core.st

+ 43 - 8
src/Helios-Core.js

@@ -3453,13 +3453,14 @@ selector: "renderContentOn:",
 protocol: "rendering",
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["html"],
-source: "renderContentOn: html\x0a\x09html ul \x0a    \x09class: self listCssClass;\x0a        with: [ self renderListOn: html ];\x0a\x09\x09onClick: [ self focus ].\x0a    html div class: self buttonsDivCssClass; with: [\x0a      \x09self renderButtonsOn: html ].\x0a        \x0a   self setupKeyBindings",
+source: "renderContentOn: html\x0a\x0a\x09|ul|\x0a\x09\x0a\x09ul := html ul \x0a    \x09\x09class: self listCssClass;\x0a        \x09with: [ self renderListOn: html ];\x0a\x09\x09\x09onClick: [ self focus ].\x0a\x09\x09\x09\x0a\x09ul asJQuery contextmenu: [ self toggleCommandsMenu. false].\x0a\x09\x09\x0a    html div class: self buttonsDivCssClass; with: [\x0a      \x09self renderButtonsOn: html ].\x0a        \x0a   self setupKeyBindings",
 referencedClasses: [],
 //>>excludeEnd("ide");
 pragmas: [],
-messageSends: ["class:", "ul", "listCssClass", "with:", "renderListOn:", "onClick:", "focus", "div", "buttonsDivCssClass", "renderButtonsOn:", "setupKeyBindings"]
+messageSends: ["class:", "ul", "listCssClass", "with:", "renderListOn:", "onClick:", "focus", "contextmenu:", "asJQuery", "toggleCommandsMenu", "div", "buttonsDivCssClass", "renderButtonsOn:", "setupKeyBindings"]
 }, function ($methodClass){ return function (html){
 var self=this,$self=this;
+var ul;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
@@ -3483,7 +3484,7 @@ return $self._renderListOn_(html);
 ,$ctx1.sendIdx["with:"]=1
 //>>excludeEnd("ctx");
 ][0];
-$recv($1)._onClick_((function(){
+ul=$recv($1)._onClick_((function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
@@ -3492,6 +3493,16 @@ return $self._focus();
 }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
 //>>excludeEnd("ctx");
 }));
+$recv($recv(ul)._asJQuery())._contextmenu_((function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+$self._toggleCommandsMenu();
+return false;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
+//>>excludeEnd("ctx");
+}));
 $2=$recv(html)._div();
 $recv($2)._class_($self._buttonsDivCssClass());
 $recv($2)._with_((function(){
@@ -3500,13 +3511,13 @@ return $core.withContext(function($ctx2) {
 //>>excludeEnd("ctx");
 return $self._renderButtonsOn_(html);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)});
 //>>excludeEnd("ctx");
 }));
 $self._setupKeyBindings();
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"renderContentOn:",{html:html})});
+}, function($ctx1) {$ctx1.fill(self,"renderContentOn:",{html:html,ul:ul})});
 //>>excludeEnd("ctx");
 }; }),
 $globals.HLListWidget);
@@ -3999,7 +4010,7 @@ $globals.HLNavigationListWidget);
 
 
 $core.addClass("HLToolListWidget", $globals.HLNavigationListWidget, "Helios-Core");
-$core.setSlots($globals.HLToolListWidget, ["model"]);
+$core.setSlots($globals.HLToolListWidget, ["model", "commandsMenuElement"]);
 $core.addMethod(
 $core.method({
 selector: "activateListItem:",
@@ -4423,7 +4434,7 @@ selector: "renderMenuOn:",
 protocol: "rendering",
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["html"],
-source: "renderMenuOn: html\x0a\x09| commands |\x0a\x09\x0a\x09commands := self menuCommands.\x0a\x09commands ifEmpty: [ ^ self ].\x0a\x09\x0a\x09html div \x0a\x09\x09class: 'btn-group cog';\x0a\x09\x09with: [\x0a\x09\x09\x09html a\x0a\x09\x09\x09\x09class: 'btn btn-default dropdown-toggle';\x0a\x09\x09\x09\x09at: 'data-toggle' put: 'dropdown';\x0a\x09\x09\x09\x09with: [ (html tag: 'i') class: 'glyphicon glyphicon-chevron-down' ].\x0a\x09\x09html ul \x0a\x09\x09\x09class: 'dropdown-menu pull-right';\x0a\x09\x09\x09with: [ \x0a\x09\x09\x09\x09commands do: [ :each | \x0a\x09\x09\x09\x09\x09html li with: [ html a \x0a\x09\x09\x09\x09\x09\x09with: each menuLabel;\x0a\x09\x09\x09\x09\x09\x09onClick: [ self execute: each ] ] ] ] ]",
+source: "renderMenuOn: html\x0a\x09| commands |\x0a\x09\x0a\x09commands := self menuCommands.\x0a\x09commands ifEmpty: [ ^ self ].\x0a\x09\x0a\x09html div \x0a\x09\x09class: 'btn-group cog';\x0a\x09\x09with: [\x0a\x09\x09\x09commandsMenuElement := html a\x0a\x09\x09\x09\x09class: 'btn btn-default dropdown-toggle';\x0a\x09\x09\x09\x09at: 'data-toggle' put: 'dropdown';\x0a\x09\x09\x09\x09with: [ (html tag: 'i') class: 'glyphicon glyphicon-chevron-down' ].\x0a\x09\x09html ul \x0a\x09\x09\x09class: 'dropdown-menu pull-right';\x0a\x09\x09\x09with: [ \x0a\x09\x09\x09\x09commands do: [ :each | \x0a\x09\x09\x09\x09\x09html li with: [ html a \x0a\x09\x09\x09\x09\x09\x09with: each menuLabel;\x0a\x09\x09\x09\x09\x09\x09onClick: [ self execute: each ] ] ] ] ]",
 referencedClasses: [],
 //>>excludeEnd("ide");
 pragmas: [],
@@ -4463,7 +4474,7 @@ $2=[$recv(html)._a()
 //>>excludeEnd("ctx");
 ][0];
 $recv($2)._at_put_("data-toggle","dropdown");
-[$recv($2)._with_((function(){
+$self.commandsMenuElement=[$recv($2)._with_((function(){
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx3) {
 //>>excludeEnd("ctx");
@@ -4575,6 +4586,30 @@ return self;
 }; }),
 $globals.HLToolListWidget);
 
+$core.addMethod(
+$core.method({
+selector: "toggleCommandsMenu",
+protocol: "actions",
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "toggleCommandsMenu\x0a\x0a\x09commandsMenuElement asJQuery dropdown: 'toggle'",
+referencedClasses: [],
+//>>excludeEnd("ide");
+pragmas: [],
+messageSends: ["dropdown:", "asJQuery"]
+}, function ($methodClass){ return function (){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+$recv($recv($self.commandsMenuElement)._asJQuery())._dropdown_("toggle");
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"toggleCommandsMenu",{})});
+//>>excludeEnd("ctx");
+}; }),
+$globals.HLToolListWidget);
+
 $core.addMethod(
 $core.method({
 selector: "unregister",

+ 17 - 6
src/Helios-Core.st

@@ -882,10 +882,16 @@ renderButtonsOn: html
 !
 
 renderContentOn: html
-	html ul 
-    	class: self listCssClass;
-        with: [ self renderListOn: html ];
-		onClick: [ self focus ].
+
+	|ul|
+	
+	ul := html ul 
+    		class: self listCssClass;
+        	with: [ self renderListOn: html ];
+			onClick: [ self focus ].
+			
+	ul asJQuery contextmenu: [ self toggleCommandsMenu. false].
+		
     html div class: self buttonsDivCssClass; with: [
       	self renderButtonsOn: html ].
         
@@ -964,7 +970,7 @@ setupKeyBindings
 ! !
 
 HLNavigationListWidget subclass: #HLToolListWidget
-	slots: {#model}
+	slots: {#model. #commandsMenuElement}
 	package: 'Helios-Core'!
 
 !HLToolListWidget methodsFor: 'accessing'!
@@ -1031,6 +1037,11 @@ reactivateListItem: anItem
 	self model withChangesDo: [ super reactivateListItem: anItem ]
 !
 
+toggleCommandsMenu
+
+	commandsMenuElement asJQuery dropdown: 'toggle'
+!
+
 unregister
 	super unregister.
 	
@@ -1062,7 +1073,7 @@ renderMenuOn: html
 	html div 
 		class: 'btn-group cog';
 		with: [
-			html a
+			commandsMenuElement := html a
 				class: 'btn btn-default dropdown-toggle';
 				at: 'data-toggle' put: 'dropdown';
 				with: [ (html tag: 'i') class: 'glyphicon glyphicon-chevron-down' ].