From Clomosy Docs

Revision as of 10:38, 11 October 2023 by ClomosyManager (talk | contribs)

Ask Method Supported Only For Windows. You can use AskAndCall.

The "Ask" function is commonly used in Clomosy programming to display a dialog box where you can request user confirmation. You can use this function to ask a question or present options to the user.

Clomosy.Ask('Do you like Clomosy?');

By using "Clomosy.Ask," you can input a specific question. If the "Yes" button is clicked, the function returns a value of true. Otherwise, it returns false, allowing you to perform the desired operations.

Example:

var
 MyForm:TCLForm;
 askBtn:TCLButton;
 getEdit :TClEdit;
 procedure ProcYes;
 begin
   ShowMessage('Yes Clicked');
 end;
 procedure ProcNo;
 begin
   ShowMessage('No Clicked');
 end;
 procedure askBtnOnClick;
 begin
  
   if getEdit.Text <> '' then
   begin
     if Clomosy.Ask(getEdit.Text) then
       ProcYes;
     else
       ProcNo;
   end else
     ShowMessage('Please enter a question.');
 end;

begin
 MyForm := TCLForm.Create(Self);
 getEdit := MyForm.AddNewEdit(MyForm, 'getEdit','Enter the question...');
 getEdit.Align:=alMostTop;
 getEdit.Margins.Top:=20;
 getEdit.Margins.Right:=20;
 getEdit.Margins.Left:=20;

 askBtn:= MyForm.AddNewButton(MyForm,'askBtn','Ask Function');
 askBtn.Align:=alTop;
 askBtn.Margins.Top:=20;
 askBtn.Margins.Right:=20;
 askBtn.Margins.Left:=20;

 MyForm.AddNewEvent(askBtn,tbeOnClick,'askBtnOnClick');

 MyForm.Run;
end;