World Wind Forums

Go Back   World Wind Forums > WorldWind JAVA forums > Development Help

Development Help Help for building applications or diagnosing problems with WWJ

Reply
 
Thread Tools Display Modes
Old 02-02-2008, 02:51 AM   #1
kjohnston
Junior Member
 
Join Date: Dec 2007
Posts: 23
kjohnston is on a distinguished road
Default Bug in AWTInputHandler mouseDragged

I am writing a FengGUI layer. In that layer, I consume the mouse event if FengGUI processes the event. However - in the mouseDragged method in AWTInputHandler - the event is not checked to see if it is consumed before setting isDragging to true. What happens is that in FengGUI, sometimes the mouse gets a little ahead of the thing being dragged, and since the AWTInputHandler thinks that dragging is enabled, the globe rotates.

I think that if the event is consumed by another listener - there should be no chance that dragging is enabled.

Right now I don't see a workaround other than subclassing the AWTInputHandler and fixing this problem.

Code:
 public void mouseDragged(MouseEvent mouseEvent)
    {
        if (this.wwd == null) // include this test to ensure any derived implementation performs it
            return;

        if (mouseEvent == null)
            return;

        Point prevMousePoint = this.mousePoint;
        this.mousePoint = mouseEvent.getPoint();
        this.callMouseDraggedListeners(mouseEvent);

        if (MouseEvent.BUTTON1_DOWN_MASK == mouseEvent.getModifiersEx())
        {
            PickedObjectList pickedObjects = this.objectsAtButtonPress;
            if (this.isDragging
                || (pickedObjects != null && pickedObjects.getTopPickedObject() != null
                && !pickedObjects.getTopPickedObject().isTerrain()))
            {
                this.isDragging = true;
                this.callSelectListeners(new DragSelectEvent(this.wwd, SelectEvent.DRAG, mouseEvent, pickedObjects,
                    prevMousePoint));
            }
        }

        if (!this.isDragging)
        {
            if (!mouseEvent.isConsumed())
            {
                this.viewInputBroker.mouseDragged(mouseEvent);
            }
        }

        // Redraw to update the current position and selection.
        if (this.wwd.getSceneController() != null)
        {
            this.wwd.getSceneController().setPickPoint(mouseEvent.getPoint());
            this.wwd.redraw();
        }
    }
kjohnston is offline   Reply With Quote
Old 02-02-2008, 06:34 AM   #2
kjohnston
Junior Member
 
Join Date: Dec 2007
Posts: 23
kjohnston is on a distinguished road
Default

Hm, maybe this is not a bug. Looks like FengGUI is not processing the drag event. I might have a workaround.
kjohnston is offline   Reply With Quote
Old 02-02-2008, 06:37 AM   #3
kjohnston
Junior Member
 
Join Date: Dec 2007
Posts: 23
kjohnston is on a distinguished road
Default

Yep - found a simple workaround. No bug in WW.
kjohnston is offline   Reply With Quote
Old 02-02-2008, 07:38 AM   #4
patmurris
WWJ Consultant
 
patmurris's Avatar
 
Join Date: Jun 2005
Location: Saint-Paul de Vence, Alpes Maritimes, France
Posts: 3,412
patmurris is an unknown quantity at this point
Default

Can you explain a bit, it may help others...
__________________
My World Wind Java Blog & WW.net Plugins page
patmurris is offline   Reply With Quote
Old 02-02-2008, 09:39 PM   #5
kjohnston
Junior Member
 
Join Date: Dec 2007
Posts: 23
kjohnston is on a distinguished road
Default

It was totally my mistake. What I ended up doing was setting a flag in the fenggui event handler when a mouse drag started, and then consuming the event if that flag was set. That way if you *start* a drag in fenggui, then it will be in effect until you stop dragging in fenggui.

I am planning to post the FengGUI layer to this forum once it is done (should be this weekend). Is there a better place to put the code? The wiki maybe?
kjohnston is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception - WWJava - AWTInputHandler AlexBowen Development Help 8 03-20-2009 04:44 AM
setInputHandler has a bit of a bug. mharris Development Help 2 02-01-2008 05:48 PM
WWJ bug at high pitch angles near terrain emaronchi Development Help 16 11-14-2007 07:56 PM
Thread bug? Hang and error message rogene Development Help 6 10-09-2007 08:14 AM
bug : VE plugin on WW SVN jp09 Add-on & Script Development 2 02-28-2007 03:26 AM


All times are GMT +1. The time now is 05:04 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.