TableView click events

Hi Ian,
I have some problem to distinguish the click-events of a tableview with virtual data. I want different actions when I click on some (!) headers, an data-row and in some data rows I have a button which I also want to track with the click-events.

For the headers I use: HeaderColumnId.onClick = … - this works

For the buttons I use the tableview.onComponentEvent = function(e)… - this works
I use e.source to get the Button and e.data to get the data row of the button.

For the data-row I use the tableview.onClick = function(e) … this is a bit unfortunate, because it fires for data rows and header rows and can’t find anything in the Event e to distinguish them. So I have to track if HeaderColumnId.onClick was fired before - but this requires me to track all HeaderColums…onClick.

I am on the html5 target and use haxeui from git. I haven’t tried if the other targets behave the same.
Is there an easier way to do what I want ?
Cheers, Adrian.

Hi Adrian,

That sounds like a bug… the way you described your usage sounds totally sensible. Ill check it out.

Cheers,
Ian

1 Like

Hi Adrian,

So actually the event you are using MouseEvent.CLICK isnt the right one… that applies to the whole control… i think the event you are after is UIEvent.CHANGE, eg:

            header1.onClick = function(e) {
                trace("header click");
            }
            tv1.onComponentEvent = function(e:ItemEvent) {
                trace("component event: " + e.itemIndex + ", " + e.source.id);
            }
            tv1.onClick = function(e) {
                trace("component clicked");
            }
            tv1.onChange = function(e) {
                trace("selection changed");
            }

That help?

Cheers,
Ian

Hi Ian,
perfect - now it’s working like expected. I didn’t realize, that the onChange Event works on TableViews.

Cheers,
Adrian.

1 Like