fiorilli Posted August 13, 2021 Share Posted August 13, 2021 Hello, I am using unisweetalert and want to use the execute method to indicate a response, however I am creating the unisweet alert at runtime in a class responsible for generating message boxes, my code is as follows: class function function TMessageUtils.UniSweetAlertQuestion(msg: string): boolean; var sweetAlert: TUniSweetAlert; begin sweetAlert := TUniSweetAlert.Create(nil); with sweetAlert do begin AlertType := atQuestion; html := msg; ConfirmButtonText := 'yes CancelButtonText := 'no'; ShowConfirmButton := true; ShowCancelButton := true; title := string.Empty; AllowEscapeKey := false; AllowOutsideClick := false; InputType := ItNone; end; if sweetAlert.Execute then result := true else result := false end; at no moment the function enters if. I did some tests and found out that the problem happens because you are passing nil when creating the component, is there any way around this? 1 Quote Link to comment Share on other sites More sharing options...
Hayri ASLAN Posted August 14, 2021 Share Posted August 14, 2021 3 hours ago, fiorilli said: Hello, I am using unisweetalert and want to use the execute method to indicate a response, however I am creating the unisweet alert at runtime in a class responsible for generating message boxes, my code is as follows: class function function TMessageUtils.UniSweetAlertQuestion(msg: string): boolean; var sweetAlert: TUniSweetAlert; begin sweetAlert := TUniSweetAlert.Create(nil); with sweetAlert do begin AlertType := atQuestion; html := msg; ConfirmButtonText := 'yes CancelButtonText := 'no'; ShowConfirmButton := true; ShowCancelButton := true; title := string.Empty; AllowEscapeKey := false; AllowOutsideClick := false; InputType := ItNone; end; if sweetAlert.Execute then result := true else result := false end; at no moment the function enters if. I did some tests and found out that the problem happens because you are passing nil when creating the component, is there any way around this? Hello You can use UniMainModule.MasterForm instead of nil sweetAlert := TUniSweetAlert.Create(UniMainModule.MasterForm); 1 1 Quote Link to comment Share on other sites More sharing options...
fiorilli Posted August 14, 2021 Author Share Posted August 14, 2021 12 hours ago, Hayri ASLAN said: Hello You can use UniMainModule.MasterForm instead of nil sweetAlert := TUniSweetAlert.Create(UniMainModule.MasterForm); thanks 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.