haxeui-kha icon indicating copy to clipboard operation
haxeui-kha copied to clipboard

Allow mouse events to mapped by custom code

Open ianharrigan opened this issue 8 years ago • 0 comments

It would be nice to allow haxeui-kha (and possibly all other backends) to inject code to handle event mapping. This would be advantageous as it allows, for example, for a HaxeUI application to be put into a 3D scene and co-ord translation logic to be applied for mouse events (instead of the default processing)

Expected Behavior

The ability to side step haxeui-kha event mapping

Current Behavior

At the moment, when haxeui-core adds an event, a mapEvent function is called in the backend, this functions holds onto the event listener and the event in question in a map, it then links up an actual event using Khas Mouse.get().notify

Possible Solution

What may be a better system is to have a class defined in module.xml, this would default to something sensible, this could then be called instead meaning that 3rd part code could be injected into the system. This class could also have an easy way to then dispatch these events via the ComponentBase

eg:

switch (type) {
    case MouseEvent.MOUSE_OVER:
        if (_eventMap.exists(MouseEvent.MOUSE_OVER) == false) {
            _mapper.map(MouseEvent.MOUSE_OVER, listener);
            _eventMap.set(MouseEvent.MOUSE_OVER, listener);
        }
}

it would be nice to get some input from @luboslenco if this makes sense and is the right way to be doing things.

ianharrigan avatar Jul 24 '16 12:07 ianharrigan