irigsoft Posted March 24, 2021 Share Posted March 24, 2021 Hello, is it possible to display a screen mask after a few seconds with some delay. If you press the button and it takes more than 2 seconds, then the screen mask will be displayed, otherwise the screen mask will not be displayed Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 25, 2021 Share Posted March 25, 2021 12 hours ago, irigsoft said: is it possible to display a screen mask after a few seconds with some delay. If you press the button and it takes more than 2 seconds, then the screen mask will be displayed, otherwise the screen mask will not be displayed Hello, In the simplest case... 1. UniButton1 -> ScreenMask -> Enabled = False 2. UniButton1 -> ClientEvents -> function afterrender(sender, eOpts) { sender.delayedTask = Ext.create('Ext.util.DelayedTask', function() { sender.btnMask = new Ext.LoadMask({ msg: 'Please wait...', target: MainForm.window //? }); sender.btnMask.show() }, this); sender.getEl().on('click', function() { sender.setDisabled(true); sender.delayedTask.delay(2000); }); } 3. procedure TMainForm.UniButton1Click(Sender: TObject); begin //some long-running task with (Sender as TUniButton).JSInterface do begin JSCall('delayedTask.cancel', []); JSCode('if ('#1'.btnMask) {'#1'.btnMask.hide()};'); JSCall('setDisabled', [False]); end; end; Quote Link to comment Share on other sites More sharing options...
irigsoft Posted March 25, 2021 Author Share Posted March 25, 2021 4 minutes ago, Sherzod said: Hello, In the simplest case... 1. UniButton1 -> ScreenMask -> Enabled = False 2. UniButton1 -> ClientEvents -> function afterrender(sender, eOpts) { sender.delayedTask = Ext.create('Ext.util.DelayedTask', function() { sender.btnMask = new Ext.LoadMask({ msg: 'Please wait...', target: MainForm.window //? }); sender.btnMask.show() }, this); sender.getEl().on('click', function() { sender.setDisabled(true); sender.delayedTask.delay(2000); }); } 3. procedure TMainForm.UniButton1Click(Sender: TObject); begin //some long-running task with (Sender as TUniButton).JSInterface do begin JSCall('delayedTask.cancel', []); JSCode('if ('#1'.btnMask) {'#1'.btnMask.hide()};'); JSCall('setDisabled', [False]); end; end; Thanks, is this posible to make this with global script on mainform? Quote Link to comment Share on other sites More sharing options...
irigsoft Posted March 25, 2021 Author Share Posted March 25, 2021 Sorry, but sender.delayedTask.delay(2000); it is not what i looking for. https://docs.sencha.com/extjs/6.5.1/classic/Ext.util.DelayedTask.html I want to start the execution by clicking the button, but if the execution takes less than 3 seconds not to show the mask on the screen, if it is more than 3 seconds, then to show the mask. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 25, 2021 Share Posted March 25, 2021 37 minutes ago, irigsoft said: Sorry, but sender.delayedTask.delay(2000); it is not what i looking for. https://docs.sencha.com/extjs/6.5.1/classic/Ext.util.DelayedTask.html I want to start the execution by clicking the button, but if the execution takes less than 3 seconds not to show the mask on the screen, if it is more than 3 seconds, then to show the mask. Here, delayedTask is exactly for showing the mask, and the code works immediately after clicking on the button. 1 Quote Link to comment Share on other sites More sharing options...
irigsoft Posted March 25, 2021 Author Share Posted March 25, 2021 5 hours ago, Sherzod said: Here, delayedTask is exactly for showing the mask, and the code works immediately after clicking on the button. OK, I try to apply this on tuniBitBtn, TunISpeedButton, tuniButton and get error after create Control, there is my code: IF TuniControl (UniMainModule.NewComponent).ClassNameIs('TuniButton') OR TuniControl (UniMainModule.NewComponent).ClassNameIs('TuniBitBtn') OR TuniControl (UniMainModule.NewComponent).ClassNameIs('TColorButton') OR TuniControl (UniMainModule.NewComponent).ClassNameIs('TUniSpeedButton') then begin TuniBitBtn (UniMainModule.NewComponent).ClientEvents.ExtEvents.Values['onafterrender'] := 'function afterrender(sender, eOpts)' + '{' + ' sender.delayedTask = Ext.create(''Ext.util.DelayedTask'', function() {' + ' sender.btnMask = new Ext.LoadMask({' + ' msg: ''Please wait...'',' + ' target: MainForm.window //?' + ' });' + ' sender.btnMask.show()' + ' }, this);' + ' sender.getEl().on(''click'', function() {' + ' sender.setDisabled(true);' + ' sender.delayedTask.delay(2000);' + ' });' + '}' end; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 25, 2021 Share Posted March 25, 2021 Just now, irigsoft said: OK, I try to apply this on tuniBitBtn, TunISpeedButton, tuniButton and get error Please make a simple testcase. Quote Link to comment Share on other sites More sharing options...
irigsoft Posted March 25, 2021 Author Share Posted March 25, 2021 Just now, Sherzod said: Please make a simple testcase. there is my code, after create Control on form creation: IF TuniControl (UniMainModule.NewComponent).ClassNameIs('TuniButton') OR TuniControl (UniMainModule.NewComponent).ClassNameIs('TuniBitBtn') OR TuniControl (UniMainModule.NewComponent).ClassNameIs('TColorButton') OR TuniControl (UniMainModule.NewComponent).ClassNameIs('TUniSpeedButton') then begin TuniBitBtn (UniMainModule.NewComponent).ClientEvents.ExtEvents.Values['onafterrender'] := 'function afterrender(sender, eOpts)' + '{' + ' sender.delayedTask = Ext.create(''Ext.util.DelayedTask'', function() {' + ' sender.btnMask = new Ext.LoadMask({' + ' msg: ''Please wait...'',' + ' target: MainForm.window //?' + ' });' + ' sender.btnMask.show()' + ' }, this);' + ' sender.getEl().on(''click'', function() {' + ' sender.setDisabled(true);' + ' sender.delayedTask.delay(2000);' + ' });' + '}' end; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 25, 2021 Share Posted March 25, 2021 4 minutes ago, irigsoft said: + ' target: MainForm.window //?' Try this: ClientEvents.ExtEvents.Values['onafterrender'] := 'function afterrender(sender, eOpts)' + '{' + ' sender.delayedTask = Ext.create(''Ext.util.DelayedTask'', function() {' + ' sender.btnMask = new Ext.LoadMask({' + ' msg: ''Please wait...'',' + ' target: MainForm.window ' + ' });' + ' sender.btnMask.show()' + ' }, this);' + ' sender.getEl().on(''click'', function() {' + ' sender.setDisabled(true);' + ' sender.delayedTask.delay(2000);' + ' });' + '}' Quote Link to comment Share on other sites More sharing options...
irigsoft Posted March 25, 2021 Author Share Posted March 25, 2021 22 minutes ago, Sherzod said: Try this: ClientEvents.ExtEvents.Values['onafterrender'] := 'function afterrender(sender, eOpts)' + '{' + ' sender.delayedTask = Ext.create(''Ext.util.DelayedTask'', function() {' + ' sender.btnMask = new Ext.LoadMask({' + ' msg: ''Please wait...'',' + ' target: MainForm.window ' + ' });' + ' sender.btnMask.show()' + ' }, this);' + ' sender.getEl().on(''click'', function() {' + ' sender.setDisabled(true);' + ' sender.delayedTask.delay(2000);' + ' });' + '}' Thanks it's ok now. but i get screenmask for milliseconds visible, maybe if mainform.screenmask is enabled this is result , did You know? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 25, 2021 Share Posted March 25, 2021 5 minutes ago, irigsoft said: but i get screenmask for milliseconds visible, maybe if mainform.screenmask is enabled this is result , did You know? 7 hours ago, Sherzod said: 1. UniButton1 -> ScreenMask -> Enabled = False Quote Link to comment Share on other sites More sharing options...
irigsoft Posted March 25, 2021 Author Share Posted March 25, 2021 2 minutes ago, Sherzod said: Yes, that was the problem, thanks 1 Quote Link to comment Share on other sites More sharing options...
irigsoft Posted March 25, 2021 Author Share Posted March 25, 2021 Now, I use Suspend and ResumeLayouts on BtnClick. after applying a method, parental control (TuniPanel, uniGroupbox) becomes deactivated TuniForm (TuniControl (sSender).OwnerForm).SuspendLayouts; ................... procedure ..................... TuniForm (TuniControl (sSender).OwnerForm).ResumeLayouts; TuniForm (TuniControl (sSender).OwnerForm).HideMask; if ((TuniControl (sSender).ClassNameIs('TUniBitBtn')) OR (TuniControl (sSender).ClassNameIs('TUniButton')) OR (TuniControl (sSender).ClassNameIs('TUniSpeedButton')) ) then begin with TUniBitBtn (sSender).JSInterface do begin JSCall('delayedTask.cancel', []); JSCode('if ('#1'.btnMask) {'#1'.btnMask.hide()};'); JSCall('setDisabled', [False]); end; end; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 25, 2021 Share Posted March 25, 2021 6 minutes ago, irigsoft said: with TUniBitBtn (sSender).JSInterface ? Quote Link to comment Share on other sites More sharing options...
irigsoft Posted March 25, 2021 Author Share Posted March 25, 2021 Just now, Sherzod said: ? I found the problem: ClientEvents.ExtEvents.Values['onafterrender'] := 'function afterrender(sender, eOpts)' + '{' + ' sender.delayedTask = Ext.create(''Ext.util.DelayedTask'', function() {' + ' sender.btnMask = new Ext.LoadMask({' + ' msg: ''Please wait...'',' + ' target: MainForm.window ' + ' });' + ' sender.btnMask.show()' + ' }, this);' + ' sender.getEl().on(''click'', function() {' + ' sender.setDisabled(true);' + ' sender.delayedTask.delay(2000);' + ' });' + '}' Quote Link to comment Share on other sites More sharing options...
irigsoft Posted March 25, 2021 Author Share Posted March 25, 2021 Thanks, now work just fine. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 25, 2021 Share Posted March 25, 2021 1 minute ago, irigsoft said: sender.setDisabled(true); This prevents multiple clicks on the button. Quote Link to comment Share on other sites More sharing options...
irigsoft Posted March 25, 2021 Author Share Posted March 25, 2021 1 minute ago, Sherzod said: This prevents multiple clicks on the button. I disable button on start of procedure executions, on server side. but this disable the parent on my project, and no enabling again Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 25, 2021 Share Posted March 25, 2021 Okay. Quote Link to comment Share on other sites More sharing options...
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.