Project

General

Profile

WTextArea doesn't show scrollbars when inside a layout wi... ยป main.cpp

Stefan Bn, 02/28/2022 12:26 PM

 
#include <Wt/WApplication.h>
#include <Wt/WBootstrap5Theme.h>
#include <Wt/WServer.h>

#include <Wt/WContainerWidget.h>
#include <Wt/WVBoxLayout.h>
#include <Wt/WTextArea.h>


using namespace Wt;



// -----------------------------------------------------------------------------------
std::unique_ptr<WApplication> createHelloApplication(const WEnvironment &env)
{
auto app = std::make_unique<Wt::WApplication>(env);

auto theme = std::make_shared<Wt::WBootstrap5Theme>();
app->setTheme(theme);

auto mainVLayout = app->root()->setLayout(std::make_unique<WVBoxLayout>());

auto ta = mainVLayout->addWidget(std::make_unique<WTextArea>(), 1);

WString longText;

for (int i = 0; i < 300; i++)
longText += "Line " + std::to_string(i) + "\n";

ta->setText(longText);

return app;
}


// -----------------------------------------------------------------------------------
int main(int argc, char *argv[])
{
try
{
WServer server(argc, argv, WTHTTP_CONFIGURATION);

server.addEntryPoint(EntryPointType::Application,
std::bind(&createHelloApplication, std::placeholders::_1));

if (server.start())
{
int sig = WServer::waitForShutdown();

std::cerr << "*** Shutdown (signal = " << sig << ")" << std::endl;
server.stop();

if (sig == 1) // SIGHUP
WServer::restart(argc, argv, environ);

return 0;
}
}
catch (WServer::Exception &e)
{
std::cerr << "*** Server Exception: " << e.what() << std::endl;
}
catch (std::exception &e)
{
std::cerr << "*** Std Exception: " << e.what() << std::endl;
}
}
    (1-1/1)