andyhill 24 Posted February 10 Share Posted February 10 Please advise how to ADD / INSERT Button into StatusBar at Runtime - thanks. procedure TMainForm.UniFormBeforeShow(Sender: TObject); begin if FirstTime = True then begin FirstTime:= False; (* INSERT UniSession.AddJS(UniStatusBar.JSName + '.items.insert '+ '(0, Ext.create '+ ' ( '+ ' "Ext.button.Button", '+ ' { '+ ' text: "Camera", '+ ' id: "_btn1", '+ ' handler: function() '+ ' { '+ ' ajaxRequest('+MainForm.WebForm.JSName+', "_btn_click_", ["btnId="+this.id]) '+ ' } '+ ' } '+ ' ) '+ '); '); // '+ UniStatusBar.JSName +'.doLayout(); *) // ADD UniSession.AddJS(UniStatusBar.JSName + '.items.add '+ '( '+ ' Ext.create '+ ' ( '+ ' "Ext.button.Button", '+ ' { '+ ' text: "Camera", '+ ' id: "_btn1", '+ ' handler: function() '+ ' { '+ ' ajaxRequest('+MainForm.WebForm.JSName+', "_btn_click_", ["btnId="+this.id]) '+ ' } '+ ' } '+ ' ) '+ '); '); // '+ UniStatusBar.JSName +'.doLayout(); end; // FirstTime end; Quote Link to post Share on other sites
Sherzod 1188 Posted February 10 Share Posted February 10 Hello, What is your issue? Quote Link to post Share on other sites
andyhill 24 Posted February 10 Author Share Posted February 10 Does Not Paint In StatusBar ? Quote Link to post Share on other sites
andyhill 24 Posted February 10 Author Share Posted February 10 doLayout (although not used in code above) also fails ? Quote Link to post Share on other sites
Sherzod 1188 Posted February 10 Share Posted February 10 15 minutes ago, andyhill said: doLayout (although not used in code above) also fails ? Try updateLayout() instead of doLayout(). Quote Link to post Share on other sites
andyhill 24 Posted February 10 Author Share Posted February 10 Yes, Thank you. Our button is very squashed (as one can imagine), what do I do to set Size and Colour ? Quote Link to post Share on other sites
andyhill 24 Posted February 10 Author Share Posted February 10 UniSession.AddJS(UniStatusBar.JSName + '.items.add '+ '( '+ ' Ext.create '+ ' ( '+ ' "Ext.button.Button", '+ ' { '+ ' text: "Camera", '+ ' id: "_btn1", '+ ' left: 10, '+ IGNORED ' width: 300, '+ ' height: 18, '+ ' color: 123, '+ IGNORED (font) ' bgcolor: 123, '+ ????? ' handler: function() '+ ' { '+ ' ajaxRequest('+MainForm.WebForm.JSName+', "_btn_click_", ["btnId="+this.id]) '+ ' } '+ ' } '+ ' ) '+ '); ' + UniStatusBar.JSName+'.updateLayout();'); Do we need to create a Panel first, then add Button in panel - How ? Quote Link to post Share on other sites
andyhill 24 Posted February 10 Author Share Posted February 10 Experimenting, How would I add listener to each Menu Item ? ' renderTo : Ext.getBody(), '+ ' arrowAlign: "right", '+ ' menu: [ '+ ' {text: "Item 1"}, '+ ' {text: "Item 2"}, '+ ' {text: "Item 3"}, '+ ' {text: "Item 4"} '+ ' ], '+ ' handler: function() '+ ' { '+ ' ajaxRequest('+MainForm.WebForm.JSName+', "_btn_click_", ["btnId="+this.id]) '+ ' } '+ Quote Link to post Share on other sites
Sherzod 1188 Posted February 10 Share Posted February 10 15 minutes ago, andyhill said: How would I add listener to each Menu Item ? Like this: Quote Link to post Share on other sites
andyhill 24 Posted February 10 Author Share Posted February 10 Great. UniSession.AddJS(UniStatusBar.JSName + '.items.add '+ '( '+ ' Ext.create '+ ' ( '+ ' "Ext.button.Button", '+ ' { '+ ' text: "Camera", '+ ' id: "_btn1", '+ ' margin: "0 5 0 5", '+ ' padding: 0, '+ ' width: 300, '+ ' height: 16, '+ ' renderTo : Ext.getBody(), '+ ' arrowAlign: "right", '+ ' menu: [ '+ ' {text: "Item 1" , iconCls: "x-fa fa-camera-retro", handler: function () {ajaxRequest('+MainForm.WebForm.JSName+', "_mnu_one_", [])}}, '+ ' {text: "Item 2" , iconCls: "x-fa fa-video", handler: function () {ajaxRequest('+MainForm.WebForm.JSName+', "_mnu_two_", [])}}, '+ ' {text: "Item 3" , iconCls: "x-fa fa-trash", handler: function () {ajaxRequest('+MainForm.WebForm.JSName+', "_mnu_three_", [])}}, '+ ' {text: "Item 4" , iconCls: "x-fa fa-print", handler: function () {ajaxRequest('+MainForm.WebForm.JSName+', "_mnu_four_", [])}}, '+ ' ] '+ (* ' handler: function() '+ ' { '+ ' ajaxRequest('+MainForm.WebForm.JSName+', "_btn_click_", ["btnId="+this.id]) '+ ' } '+ *) ' } '+ ' ) '+ '); ' + UniStatusBar.JSName+'.updateLayout();'); How can I align the button vertically (paint button in the middle of the StatusBar) - it appears as top=4 ? Also, Hide/Show Button at runtime ? and finally Enable/Disable Menu Items at runtime ? Quote Link to post Share on other sites
andyhill 24 Posted February 12 Author Share Posted February 12 Sherzod, Hide/Show MenuButton at runtime ? Enable/Disable MenuButton Items at runtime ? Quote Link to post Share on other sites
andyhill 24 Posted February 13 Author Share Posted February 13 Sherzod, Using Ext.button.Button Menu - Please advise how to:- Hide/Show Ext.button.Button at runtime ? Enable/Disable Ext.button.Button Menu Items at runtime ? Thanks Quote Link to post Share on other sites
Sherzod 1188 Posted February 14 Share Posted February 14 Hello, I will check. Quote Link to post Share on other sites
Sherzod 1188 Posted February 15 Share Posted February 15 On 2/10/2021 at 2:26 PM, andyhill said: Also, Hide/Show Button at runtime ? procedure TMainForm.UniButton1Click(Sender: TObject); begin UniStatusBar.JSInterface.JSCall('down("#_btn1").hide', []); //or show end; Quote Link to post Share on other sites
Sherzod 1188 Posted February 15 Share Posted February 15 On 2/10/2021 at 2:26 PM, andyhill said: and finally Enable/Disable Menu Items at runtime ? For example by Index: procedure TMainForm.UniButton2Click(Sender: TObject); begin // first item - getComponent(0), second item - getComponent(1)... UniStatusBar.JSInterface.JSCall('down("#_btn1").getMenu().getComponent(0).setDisabled', [True]); // or False end; Quote Link to post Share on other sites
andyhill 24 Posted February 15 Author Share Posted February 15 Thank You Sherzod, very much appreciated Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.