Jump to content

TUniScreenMask


picyka

Recommended Posts

Working with the component TUniScreenMask and we have the following scenario: When using a shortcut key to trigger the click of a button, the component TUniScreenMask is not triggered, activating only when using the mouse to click on.

Link to comment
Share on other sites

  • Administrators

Working with the component TUniScreenMask and we have the following scenario: When using a shortcut key to trigger the click of a button, the component TUniScreenMask is not triggered, activating only when using the mouse to click on.

 

How do you use a shortcut key in web mode?

Link to comment
Share on other sites

  • Administrators

You call a server side click which has no effect on a client side mask.

 

Solution:

 

object MainForm: TMainForm
 Left = 0
 Top = 0
 Caption = 'MainForm'
 ClientHeight = 74
 ClientWidth = 232
 Color = clBtnFace
 OldCreateOrder = False
 Script.Strings = (
'function sendProc(sender)'
'{'
'   sender.showMask('#39'Sending...'#39');'
'   ajaxRequest(sender, '#39'sendEvent'#39', []);'
'}   	')
 ClientEvents.ExtEvents.Strings = (

 	'1-Onkeydown=function form.Onkeydown(sender, key, shift)'#13#10'{'#13#10'   i' +
 	'f (key==121) {'#13#10' 	sendProc(sender);  	'#13#10'   }'#13#10'}')
 MonitoredKeys.Keys = <
item
 	KeyStart = 121
 	KeyEnd = 121
end>
 OnAjaxEvent = UniFormAjaxEvent
 PixelsPerInch = 96
 TextHeight = 13
 object UniEdit4: TUniEdit
Left = 56
Top = 10
Width = 121
Height = 22
PasswordChar = #0
CharCase = ecNormal
MaxLength = 0
CharEOL = #0
TabOrder = 0
Color = clWindow
 end
 object btnSend: TUniBitBtn
Left = 56
Top = 38
Width = 121
Height = 25
Caption = 'Send [F10]'
TabOrder = 1
ClientEvents.ExtEvents.Strings = (
 	
   	'OnClick=function OnClick(sender, e)'#13#10'{'#13#10'  sendProc(MainForm.form' +
   	');'#13#10'}')
OnClick = btnSendClick
 end
end

 


unit Main;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics,
 Controls, Forms, Dialogs, uniGUITypes, uniGUIAbstractClasses,
 uniGUIClasses, uniGUIForm, uniGUIBaseClasses, uniEdit, uniButton, uniBitBtn,
 uniScreenMask;

type
 TMainForm = class(TUniForm)
UniEdit4: TUniEdit;
btnSend: TUniBitBtn;
procedure UniFormAjaxEvent(Sender: TComponent; EventName: string;
 	Params: TStrings);
procedure btnSendClick(Sender: TObject);
 private
{ Private declarations }
 public
{ Public declarations }
 end;

function MainForm: TMainForm;

implementation

{$R *.dfm}

uses
 uniGUIVars, MainModule;

function MainForm: TMainForm;
begin
 Result := TMainForm(UniMainModule.GetFormInstance(TMainForm));
end;

procedure TMainForm.btnSendClick(Sender: TObject);
begin
 if not WebMode then
Sleep(5000);
end;

procedure TMainForm.UniFormAjaxEvent(Sender: TComponent; EventName: string;
 Params: TStrings);
begin
 if EventName='sendEvent' then
Sleep(5000);
end;

initialization
 RegisterMainFormClass(TMainForm);

end.

Link to comment
Share on other sites

It worked perfectly, one more doubt heheheh

is to use only one component TUniScreenMask to more than one component? food AttachedControl property at runtime? avoid using more than one TUniScreenMask in that Form.

 

thank you

Link to comment
Share on other sites

It worked perfectly, one more doubt heheheh

is to use only one component TUniScreenMask to more than one component? food AttachedControl property at runtime? avoid using more than one TUniScreenMask in that Form.

 

thank you

 

 

It would be nice if it had a list of objects, that would solve the problem

 

Thank you.

Link to comment
Share on other sites

  • 6 years later...

For what it's worth, the above example didn't work as-is in the latest UniGUI version(s).  I've updated it, added a few logging calls and instructions to make it clearer what's happening, as well as changing the flow somewhat (avoiding using a custom event in favour of just triggering the actual button click instead.)  The code is available here:

https://github.com/ByteJuggler/uni_keycap/tree/master

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...