How can simulate mouseClick on a component?

I was wondering how I could simulate event.

I tried
var e = new haxe.ui.events.MouseEvent(haxe.ui.events.MouseEvent.MOUSE_DOWN);
component.dispatch(e);

and it doesn’t seem to do anything.

Thanks :slight_smile:

In fact it does seem to work :slightly_smiling_face: for normal buttons
Now I try to click on accordion buttons

I guess it depends on the default action bound to MOUSE_DOWN for each component

1 Like

As Sartoric says, its may work, but its not intentional… its just that you are triggering an event that the component is listening to internally.

Ie, if you dispatched a mouse down on a slider button and then a mouse move it certainly wouldnt work, thought a mouse down on a slider bar with the right x/y coords would work… but its not designed to work this way, its just that you are mimicking what the component is looking for.

What are you actually trying to do?

Are you trying to programmatically open a panel in the accordion, if there isnt an api call for that, there should be

Cheer,
Ian

Yes , that’s what I was trying to do, finally I was able to do it programmatically, by changing the pageIndex.
But I was trying to figure out by using MouseEvents. Like this, for example, for doing demos ( which explain the interface to a user) it is easier. I thought that mimicking a mouse down on a accordion button ( which has the according accordion-button class )would work.

Did it work with mouse down? I guess it did? If not MouseEvent.CLICK might work, but again, the components werent designed to work this way, so if it does work its kinda a fluke / happy accident. :slight_smile:

That said, i have an “action manager” in the pipeline that will allow for UI navigation via things like gamepads and remote controls and one of the new features that exposes is component “actions”, so you can do things like: myButton.performAction("press") and myButton.performAction("release"), this type of thing might help in the future for things like that… maybe

Cheers,
Ian

1 Like

MouseEvent.DOWN works for normal buttons, but not accordion buttons.

Checking …

Indeed MouseEvent.CLICK works with accordion buttons :slight_smile:

Oh awesome for the action manager. I think it will totally work !

1 Like