haxeui / haxeui-core

The core library of the HaxeUI framework
http://haxeui.org
MIT License
347 stars 72 forks source link

ListView selectedIndex / selectedItem is the previous one on ItemEvent.COMPONENT_EVENT #353

Closed KanedaFr closed 4 years ago

KanedaFr commented 4 years ago

Expected Behavior

on ItemEvent.COMPONENT_EVENT, reading the selectedIndex / selectedItem should return the current selected item

Current Behavior

return the previous selected item (include -1/null at first) while event.data is right

Possible Solution

don't care about selectedIndex, only use event.data

Steps to Reproduce (for bugs)

use component explorer https://github.com/haxeui/component-explorer/blob/master/src/views/ListViewsView.hx add

lv1.registerEvent( ItemEvent.COMPONENT_EVENT, onItemChange);

public function onItemChange(e:ItemEvent) {
       trace(e.data);
       trace(lv1.selectedIndex);
    }

Media

n/a

Context

Show more details about selectedItem, on click

Your Environment

OSX, hxwidgets backend

ianharrigan commented 4 years ago

Im not sure i understand. COMPONENT_EVENT is different to the CHANGE event in ListView.

The COMPONENT_EVENT is dispatched when a sub component (like a button, or a slider, or a checkbox) is used in a custom item renderer.

The CHANGE event is dispatched when the actual selectedIndex of the actual listview changes.

Am i misunderstanding the issue?

Ian

KanedaFr commented 4 years ago

I wrongly understood this post on the forum https://community.haxeui.org/t/cant-see-the-listview-text/130/3

I moved to UIEvent.CHANGE and every worked as expected. Sorry for this.

NAB