pharo-graphics / Toplo

A widget framework on top of Bloc
MIT License
19 stars 9 forks source link

Selection bug when checkbox in list #219

Open Nyan11 opened 2 hours ago

Nyan11 commented 2 hours ago

The labels do not displayed correctly when toggle buttons are in list.

image

Reproduce

group := ToCheckableGroup new.
moveListElement := ToListElement new.
moveListElement selectionMode selectOnMouseDown: false.
moveListElement nodeBuilder: [ :node :move :holder |
    | moveElement moveNumberLabel whiteMoveLabel moveButtons blackMoveLabel |
    moveButtons := OrderedCollection new.
    moveElement := BlElement new.
    moveElement layout: BlLinearLayout horizontal.
    moveElement margin: (BlInsets all: 5).
    moveElement constraintsDo: [ :c |
        c vertical fitContent.
        c horizontal fitContent ].

    moveNumberLabel := BlTextElement new.
    moveNumberLabel text: move first asString asRopedText.
    moveNumberLabel constraintsDo: [ :c | 
        c linear vertical alignCenter.
        c horizontal exact: 30 ].

    whiteMoveLabel := ToToggleButton new.
    whiteMoveLabel size: 30 @ 20.
    whiteMoveLabel labelText: move second asString asRopedText.
    moveButtons add: whiteMoveLabel.

    blackMoveLabel := ToToggleButton new.
    blackMoveLabel size: 30 @ 20.
    blackMoveLabel labelText: move third asString asRopedText.
    moveButtons add: blackMoveLabel.
    blackMoveLabel addStamp: #link.

    moveElement addChild: moveNumberLabel.
    moveElement addChild: whiteMoveLabel.
    moveElement addChild: blackMoveLabel.

    moveNumberLabel constraintsDo: [ :c | c ignored vertical alignCenter ].

    moveButtons do: [ :e | group register: e ].
    node addChild: moveElement
].
moveListElement size: 800 @ 600.
moveListElement dataAccessor addAll: { { 1. 'e4' . 'e5'} . {2. nil . nil} }.

space := BlSpace new.
space root addChild: moveListElement.
space pulse.
space resizable: true.
space show

Execute the code in playground. Click on all toggle buttons and select a line in the list.

Nyan11 commented 2 hours ago

In Toplo, the space assigned states to each elements. The state determine if a skin need to be installed, when an element is hover or pressed, or when an element is selected or unselected. Then each element can see if it has a new state and if so, the element can changed its look (visual properties) based on its skin.

The bug is trigger because the ToLabel element of the toggle button receive a ToSelectionState caused by the ToListElement. So when the label apply a "selection state" it's color change.

To debug it you can place two debug points

It is a Toplo bug.

OR