WDialog behaviour in a mobile browser
Added by Mario Diethelm 24 days ago
Hi,
Is there any razon for a WDialog (asynchronous modal dialog) behaves different in a mobile browser from a Web browser?
I have a class that executes some tasks and allows the caller display a message while the tasks are executed, using a class's method that invokes WDialog setHidden(false) to show a customized message on screen. The WDialog object is a private data member of the class. Upon finishing the tasks, the class issues a Signal (Wt::Signal<>) informing the end of the tasks and then the caller should invoke another class method to close the WDialog (the method executes setHidden(true) over the class's WDialog object). This works fine in a Web browser (the message informing "i am busy" displays correctly and upon finishing the class activities it disappears) but it does not work when used from a mobile browser (I have tested it with Chrome, Edge and FireFox, same results). The message informing "i am busy" does appear correctly, the task sequence is executed correctly, the Signal is issued and the caller actually activates the method linked to the signal but when the caller calls the message closing method, the dialog remains active blocking all the UI (is a modal dialog by design).
The application server uses the httpd connector and was build using Visual Studio C++ 2022 for x64 environments with Wt 4.11.0.
I would appreciate any suggestions. Thanks a lot.
Replies (2)
RE: WDialog behaviour in a mobile browser - Added by Matthias Van Ceulebroeck 19 days ago
Hello Mario,
I created a very small working example, to replicate the issue you are having. I'm afraid I do not see the behavior you are experiencing. Could you provide me with some sample code that does show the blocking dialog for you?
#include <Wt/WApplication.h>
#include <Wt/WBootstrap5Theme.h>
#include <Wt/WContainerWidget.h>
#include <Wt/WDialog.h>
#include <Wt/WPushButton.h>
#include <Wt/WTimer.h>
class DialogApplication : public Wt::WApplication
{
public:
DialogApplication(const Wt::WEnvironment& env)
: Wt::WApplication(env)
{
setTheme(std::make_shared<Wt::WBootstrap5Theme>());
// Create the "work" button
auto workBtn = root()->addNew<Wt::WPushButton>("Push me for work.");
workBtn->clicked().connect(this, &DialogApplication::performWork);
doneSignal_.connect(this, &DialogApplication::setWorkDialogHidden);
}
private:
Wt::WDialog* workDialog_ = nullptr;
Wt::Signal<> doneSignal_;
void performWork()
{
if (!workDialog_) {
workDialog_ = root()->addChild(std::make_unique<Wt::WDialog>());
workDialog_->setWindowTitle("Performing work");
workDialog_->contents()->addNew<Wt::WText>("Doing something for 2 seconds");
}
workDialog_->setHidden(false);
Wt::WTimer* timer = addChild(std::make_unique<Wt::WTimer>());
timer->timeout().connect(this, &DialogApplication::doneWork);
timer->setInterval(std::chrono::seconds(2));
timer->setSingleShot(true);
timer->start();
}
void doneWork()
{
doneSignal_.emit();
}
void setWorkDialogHidden()
{
workDialog_->setHidden(true);
}
};
int main(int argc, char **argv)
{
return Wt::WRun(argc, argv, [](const Wt::WEnvironment& env) {
return std::make_unique<DialogApplication>(env);
});
}
Best regards,
Matthias
RE: WDialog behaviour in a mobile browser - Added by Mario Diethelm 17 days ago
Hello Matthias,
thanks a lot for your feedback and support. I have modified your example to better resemble the structure that I have implemented in my application (a "working class" that do the job, a "consumer class" that uses the "working class" and synchronize events through the signals issued by the "working class"). In the example the "working class" is derived from Wt::WResource just to follow the general structure of my application.
Anyway the working example works fine in both web browsers and mobile browser so I will have to deep dive into my code to figure out what is going on. Again, thanks a lot.
Best regards,
Mario
testDialog.cpp (3.37 KB) testDialog.cpp |