Incorrect on_clicked propagation by HBox and VBox.

Bug #1204852 reported by Adam Malinowski
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Millennium Duel
Fix Released
High
Adam Malinowski

Bug Description

In function

HBox::on_clicked

there is a piece of code:

    for(auto i : children){
        sum += i.size;
        if(p.x <= sum) { // This item was clicked!
            i.item.on_clicked(SCoordinates(p.x - sum, p.y));
            return;
        }
        sum += spacing;
        if(p.x <= sum){ // Empty space between items was clicked
            return;
        }
    }

It probably causes click event to be propagated to item i with wrong coordinates. Line

            i.item.on_clicked(SCoordinates(p.x - sum, p.y));

should be replaced with

            i.item.on_clicked(SCoordinates(p.x - (sum - i.size), p.y));

or, more elegantly, addition to sum could be delayed:

    for(auto i : children){
        if(p.x <= sum + i.size) { // This item was clicked!
            i.item.on_clicked(SCoordinates(p.x - sum, p.y));
            return;
        }
        sum += i.size;
        sum += spacing;
        if(p.x <= sum){ // Empty space between items was clicked
            return;
        }
    }

The same bug affects function VBox::on_clicked.

Revision history for this message
Adam Malinowski (adayah) wrote :

Note: this bug had not been discovered before, because we had only used buttons inside Boxes. Buttons do not care about the coordinates they're clicked at.

Changed in millenniumduel:
assignee: Rafał Cieślak (rafalcieslak256) → Adam Malinowski (adayah)
Adam Malinowski (adayah)
Changed in millenniumduel:
status: Triaged → In Progress
Adam Malinowski (adayah)
Changed in millenniumduel:
status: In Progress → Fix Committed
Changed in millenniumduel:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.