Project

General

Profile

BUG in git version of WTrewwView; souce code attached

Added by Mohammed Rashad about 13 years ago

There is a bug is git version and wt-3.1.8 of WTreeView.

In the code given below the click event is not triggered when checkable WStandarItem of WtreeView. When clicking on the item the click event is triggered but no click event is called when toggle the checkbox of item in WTreeView. this may be a bug is WTreeView or WStandardItem

anyone please run the code and toggle the checkbox in the treeview item. code is self explanatory and the error is reproducable

But no error in wt-3.1.7a but i need to use wt-3.1.8 or git version for my application.

please fix the bug and let me know

#include

#include

#include

#include

#include

#include

using namespace Wt;

using namespace std;

class HelloApplication : public WApplication

{

public:

HelloApplication(const WEnvironment& env);

void ItemChecked();

private:

WTreeView *treeview_;

};

HelloApplication::HelloApplication(const WEnvironment& env)

: WApplication(env)

{

setTitle("Hello world");

treeview_ = new WTreeView(root());

WStandardItemModel *model = new WStandardItemModel(0, 1, this);

model->setHeaderData(0, Horizontal,

boost::any(string("Layer Tree")));

WStandardItem *result = new WStandardItem("item1");

result->setFlags(ItemIsSelectable|ItemIsUserCheckable);

result->setCheckState(Checked);

model->appendRow(result);

treeview_->setModel(model);

treeview_->clicked().connect(this,&HelloApplication::ItemChecked);

}

void HelloApplication::ItemChecked() {

WApplication::instance()->doJavaScript("alert(0);");

}

WApplication *createApplication(const WEnvironment& env)

{

return new HelloApplication(env);

}

int main(int argc, char **argv)

{

return WRun(argc, argv, &createApplication);

}


Replies (5)

RE: BUG in git version of WTrewwView; souce code attached - Added by Koen Deforche about 13 years ago

Hey Mohammed,

This is an edge case though: I am not sure if the user expects that clicking on the checkbox will at the same toggle the checkbox state and select the row ?

We have actually added the event propagation because it appeared to behave unexpected.

Regards,

koen

RE: BUG in git version of WTrewwView; souce code attached - Added by Mohammed Rashad about 13 years ago

but it in wt-3.1.7a it works when i toggle checkbox the click event is triggered. As a user we need the event to be triggered when checkbox is toggled

please add this

RE: BUG in git version of WTrewwView; souce code attached - Added by B Sorensen about 13 years ago

Hi,

I noted this same behaviour change from 3.1.7 to 3.1.8, where we no longer get callbacks when the user changes state of a checkbox within a treeview. I agree, that the user does not necessarily want to have the line selected when changing state of a checkbox, but in some cases I would like a callback on user changing the state of the checkbox, in order to control some GUI functionality.

Is there another way to subscribe to information on checkbox changes in a treeview, as an alternative to selectionChanged()?

RE: BUG in git version of WTreeView; souce code attached - Added by Koen Deforche about 13 years ago

Hey all,

The checkbox state is saved as data in the model. When the user toggles the checkbox, the model's data is updated. You can (and should) catch this event through the model, e.g. by listening to the dataChanged() signal (but that signal doesn't provide information on what data changed and what the previous state was).

Regards,

koen

RE: BUG in git version of WTrewwView; souce code attached - Added by B Sorensen about 13 years ago

Ok, I tried to connect the dataChanged(), and it seems to work ok for my needs. I'm getting the callbacks when toggling the checkbox, so I just have to implement a way to check for which line has changed in the view.

Thanks.

    (1-5/5)