Bug #1072
closedButtons become unclickable in layouts with images and nonzero stretch factors
0%
Description
Hi,
It looks to me like WHBoxLayout and WVBoxLayout may have a bug when dealing with images. I narrowed the problem down to a test case (code below). In short, in layouts that contain an image and an element with a non-zero stretch factor, two problems appear:
1) Images are rendered across div (WContainerWidget) boundaries
2) Buttons that are placed in elements after the stretch are unclickable
The "unclickable" buttons are always unclickable on a freshly loaded browser (Firefox, Chrome, Safari). Sometimes, they can become clickable after other buttons on the page have been used.
In the test case I have a nested layout that uses a WHBoxLayout and a WVBoxLayout. Without the image, everything works fine. When the image is added, the image size seems to be ignored and it is rendered across the div boundary. Buttons in elements before the stretch element work as expected, but the button placed after it is apparently invisible to the browser. Any other widgets placed after the stretch also don't respond to events.
MyApplication::MyApplication(const WEnvironment& env):
WApplication(env)
{
useStyleSheet("CssStyleSheet.css"); //Just background-color to highlight where the divs are
//A vertical box layout fills out the root widget and contains two WContainerWidgets
WVBoxLayout* vLayout=new WVBoxLayout(root());
WContainerWidget *topContainer, *bottomContainer;
topContainer=new WContainerWidget; bottomContainer=new WContainerWidget;
vLayout->addWidget(topContainer);
vLayout->addWidget(bottomContainer);
topContainer->setStyleClass("grey");
vLayout->setStretchFactor(bottomContainer,1); //bottom container takes up all unused space
//A horizontal box layout fills out the topContainer and has four WContainerWidgets in it
WHBoxLayout* topLayout=new WHBoxLayout(topContainer);
WContainerWidget *topDiv1, *topDiv2, *topDiv3, *topDiv4;
topDiv1=new WContainerWidget; topDiv2=new WContainerWidget;
topDiv3=new WContainerWidget; topDiv4=new WContainerWidget;
topLayout->addWidget(topDiv1);
topLayout->addWidget(topDiv2);
topLayout->addWidget(topDiv3);
topLayout->addWidget(topDiv4);
topLayout->setStretchFactor(topDiv3,1); //Third WContainerWidget takes up all unused space
//An image is placed into the first top WContainerWidget
//Without the image, the bug does not show up
WImage* image=new WImage("Blue rectangle.jpg",topDiv1); //?? Image is rendered across the div boundary!
//Three buttons are added to containers 2,3, and 4. The one after the stretched element (topDiv3)
//Is unclickable
WPushButton *button2, *button3, *button4;
button2=new WPushButton(WString("Button 2"),topDiv2); //Clickable
button3=new WPushButton(WString("Button 3"),topDiv3); //Clickable
button4=new WPushButton(WString("Button 4"),topDiv4); //Unclickable!!
}
Files
Updated by Koen Deforche over 13 years ago
- Status changed from New to InProgress
- Assignee set to Koen Deforche
- Target version set to 3.2.0
Updated by Peter K over 13 years ago
- File Firefox_result.png Firefox_result.png added
- File IE9_result.png IE9_result.png added