|
<< Click to Display Table of Contents >> Navigation: Forum > Buttons of ModalWindow - enabled:= true / false |
03-11-2021, 10:00 AM:
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?
03-11-2021, 10:52 AM:
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;
03-11-2021, 12:04 PM:
(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.
11-14-2022, 10:11 AM:
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