Project

General

Profile

Actions

Support #4490

closed

connection to pushbutton does not work

Added by Vassilios Kotaidis over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
09/21/2015
Due date:
% Done:

0%

Estimated time:

Description

Hello together,

modifying the code used for the Wt homepage like below does show the button and the edit field but

the action of the button (showDialog()) is not triggered.

WWidget *WtHome::example(const char *textKey, const std::string& sourceDir)

{

WContainerWidget *result = new WContainerWidget();

result->addWidget(linkSourceBrowser(sourceDir));

Wt::WTemplate *t = new Wt::WTemplate(tr(textKey), result);

t->setInternalPathEncoding(true);

t->bindWidget("name-edit", new Wt::WLineEdit());

Wt::WPushButton *saveButton = new Wt::WPushButton("Save", result);

t->bindWidget("save-button", saveButton);

Wt::WText *out = new Wt::WText(result);

out->setStyleClass("help-block");

saveButton->clicked().connect(std::bind([=] () {

showDialog(out);

}));

return result;

}

void WtHome::showDialog(Wt::WText *out)

{

Wt::WDialog *dialog = new Wt::WDialog("Go to cell");

...

dialog->show();

}

Greetings

Actions #1

Updated by Koen Deforche over 8 years ago

  • Status changed from New to Feedback

Hey,

It looks like it should work. Can you attach the complete modified sources so that can investigate?

Koen

Actions #2

Updated by Vassilios Kotaidis over 8 years ago

Hello Koen,

I checked saveButton->clicked().isConnected(), it returns true.

But I found the problem after trying around :)

original code where showDialog() is not triggered:

examplesMenu_addTab(wrapView(&WtHome::loadData),tr("load-data"))>setPathComponent("");

new code where showDialog() is triggered:

examplesMenu_addTab(loadData(), tr("load-data"))>setPathComponent("");

The difference is explained in a comment in the file WtHome.cpp (see below).

So, wrapView() does not disconnect the signal, but prevents it from being triggered. Design error of wrapView()?

Greetings

Vassili

/*

  • The following code is functionally equivalent to:
  • examplesMenu_->addTab(loadData(), "Hello world");
  • However, we optimize here for memory consumption (it is a homepage
  • after all, and we hope to be slash-dotted some day)
  • Therefore, we wrap all the static content (including the tree
  • widgets), into WViewWidgets with static models. In this way the
  • widgets are not actually stored in memory on the server.
    */
Actions #3

Updated by Koen Deforche over 8 years ago

  • Status changed from Feedback to Resolved

Hey,

That's indeed a gotcha, but it's correct. A connected signal only works if the 'signal' still exists server-side, which isn't the case for a wrap-view'ed widget.

Koen

Actions #4

Updated by Koen Deforche over 8 years ago

  • Status changed from Resolved to Closed
Actions #5

Updated by Koen Deforche over 8 years ago

  • Target version changed from 3.3.4 to 3.3.5
Actions

Also available in: Atom PDF