amitsarangi / mt4j

Automatically exported from code.google.com/p/mt4j
GNU General Public License v2.0
0 stars 0 forks source link

getCurrentTarget() for MTInputEvent #9

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Besides getting the target component of an input event it would be useful to 
have something like 
getCurrentTarget() that would return the specific sub-component when dealing 
with composites. 

    public MTComponent getCurrentTarget() {
    AbstractCursorInputEvt inputEvent = (AbstractCursorInputEvt) e;
    MTComponent[] children = target.getChildren();
    for (MTComponent child : children) {
        if (!child.pick(getCursor().getCurrentEvtPosX(), getCursor().getCurrentEvtPosY()).isEmpty()) {
        return child;
        }
    }
    return null;
    }

Original issue reported on code.google.com by getflour...@gmail.com on 20 Apr 2010 at 8:44

GoogleCodeExporter commented 9 years ago

Original comment by sirhc.f...@gmail.com on 29 Jul 2010 at 5:35

GoogleCodeExporter commented 9 years ago
There now is a getCurrentTarget() method for MTInputEvent. But it works a bit 
different. Input events can now bubble up the component hierarchy if 
inEvent.stopPropagation() is not called. 
To know on what component the event was triggered initially you can use the 
getCurrentTarget() method.

Original comment by sirhc.f...@gmail.com on 16 Nov 2010 at 5:07