Atozed Forums
Buttons of ModalWindow - enabled:= true / false - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: Buttons of ModalWindow - enabled:= true / false (/thread-2321.html)



Buttons of ModalWindow - enabled:= true / false - I.Igor - 03-11-2021

Hello.
How do I control the accessibility of buttons in a modal window?
In delphi, I would do something like this:

  Button1.Enabled: = ChechkBox1.Checked and (ComboBox.ItemIndex <> -1);

But in IWModalWindow Buttons is a TStringList. How do I access the properties of buttons? I've tried  like this :
var
  Button: TIWButton;
begin
  Button: = TIWButton (ModalWindow.Buttons.Objects[0]);
  Button.Enabled: = false  // Button = nil
end;
But it doesn't work.

Or not to use ModalWindow.Buttons for such cases? Just use the standard buttons taken from the palette and added inside the ModalWindow panel?


RE: Buttons of ModalWindow - enabled:= true / false - Jose Nilton Pace - 03-11-2021

Hi, see this demo.
Code:
  with IWModalWindow1 do begin
    Reset;
    Buttons.CommaText := '&Yes,&No,&Cancel,"I give &up|NoClose"';
    ...
    Show;
  end;
Code:
procedure TIWForm60.WindowDoOnAsyncClick(Sender: TObject; EventParams: TStringList);
var
  BtnCaption: string;
begin
  if IWModalWindow1.ButtonIndex >= 0 then begin
    BtnCaption := IWModalWindow1.ButtonCaption[IWModalWindow1.ButtonIndex]; // First ButtonIndex is 1, not 0
    WebApplication.ShowMessage('You clicked on button: ' + BtnCaption);
  end;
end;



RE: Buttons of ModalWindow - enabled:= true / false - I.Igor - 03-11-2021

(03-11-2021, 10:52 AM)Jose Nilton Pace Wrote: Hi, see this demo.
Code:
  with IWModalWindow1 do begin
    Reset;
    Buttons.CommaText := '&Yes,&No,&Cancel,"I give &up|NoClose"';
    ...
    Show;
  end;
Code:
procedure TIWForm60.WindowDoOnAsyncClick(Sender: TObject; EventParams: TStringList);
var
  BtnCaption: string;
begin
  if IWModalWindow1.ButtonIndex >= 0 then begin
    BtnCaption := IWModalWindow1.ButtonCaption[IWModalWindow1.ButtonIndex]; // First ButtonIndex is 1, not 0
    WebApplication.ShowMessage('You clicked on button: ' + BtnCaption);
  end;
end;

Thank you Jose,
I've seen this example earlier.
This example does not answer my question.
Using the NoClose parameter, you can set the button behavior before the modal window appears.
I want to control the behavior of the button while the modal is already open.


RE: Buttons of ModalWindow - enabled:= true / false - Blanca80 - 11-14-2022

Hello,
in this example Buttons.CommaText := '&Yes,&No,&Cancel,"I give &up|NoClose"';

The selected button is for default yes, always the first button, is there any possibly to set another button as default?

Thank you very much.

kind regards,

Blanca