×

Discussion Board

Results 1 to 5 of 5

Hybrid View

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    3

    Problem with mousedown/mouseup events

    Hello.

    I'm trying to create a rectangle on map with single mouse move (like in Photoshop, GIMP etc).
    I removed behaviour component and added listeners:
    Code:
    map.addListener("mousemove", onMouseMove);				
    map.addListener("mousedown", onDragStart);				
    map.addListener("mouseup", onDragEnd);
    But when I press left mouse button and then move mouse over the map, no "mouse move" event occurs.
    Also, when I release button, no "mouse up" event occurs.

    But, when I click left mouse buttons, both "mouse down" and "mouse up" events occurs simultaneously.

    Is it normal behavior?

  2. #2
    Regular Contributor
    Join Date
    Aug 2011
    Location
    Berlin
    Posts
    288

    Re: Problem with mousedown/mouseup events

    But when I press left mouse button and then move mouse over the map, no "mouse move" event occurs.
    Also, when I release button, no "mouse up" event occurs.
    This is because the drag event is fired instead of mousemove if the button is down.
    Similarly dragend is fired instead of mouseup.

    But, when I click left mouse buttons, both "mouse down" and "mouse up" events occurs simultaneously.
    This is to be expected as a click will be a mousedown followed by a mouseup. If you press down and then move the mouse, you'll get mousedown, drag and dragend instead,


    The best way to work out what is happening is to send, lots of debug to the console.
    Try this snippet below and look at the console output in FireBug to see all the various events being fired.

    Code:
    var map = new nokia.maps.map.Display(
    		document.getElementById("map"), {
    //		components: [new nokia.maps.map.component.Behavior()],
    		zoomLevel: 11,
    		center: [38.4188500, 27.1287200]
    		}
    );
    
    map.addListener("mousemove", function(evt) {	 
    	console.log(evt);
    });
    
    map.addListener("mouseup", function(evt) {	 
    	console.log(evt);
    });
    
    map.addListener("mousedown", function(evt) {	 
    	console.log(evt);
    });
    
    map.addListener("drag", function(evt) {	 
    	console.log(evt);
    });
    
    map.addListener("dragstart", function(evt) {	 
    	console.log(evt);
    });
    
    map.addListener("dragend", function(evt) {	 
    	console.log(evt);
    });

  3. #3
    Registered User
    Join Date
    Mar 2012
    Posts
    3

    Re: Problem with mousedown/mouseup events

    Thanks.
    Now I'm getting all the events I want, but I still have a little problem.

    I read API reference and realized that DragEvent doesn't have any members with geodetic coords in it.
    Is has only screen coords (available via nativeEvent member).
    Here is the link to the test page:
    http://software.scanex.ru/test/test.html

    It does work in IE, but it doesn't work in firefox (because nativeEvent is unedfined).
    Next problem: when mouse is down, I am unable to create polygons.

    Is the test file I placed a button, which creates test polygon and added a code to draw polygons on mouse drag.
    No polygon is drawn in the second case.
    Is there any way to fix this?

    Thanks for the further help.

  4. #4
    Regular Contributor
    Join Date
    Aug 2011
    Location
    Berlin
    Posts
    288

    Re: Problem with mousedown/mouseup events

    Rather than using clientX and clientY, which as you noticed are somewhat erratically supported, you can use displayX and displayY

    i.e. instead of:
    Code:
    var domEvent = fixEvent(event.nativeEvent);				
    var coord = map.pixelToGeo(domEvent.clientX, domEvent.clientY);
    use the following:
    Code:
    var coord = 	map.pixelToGeo(event.displayX, event.displayY);
    If you add this throughout it will solve the "unable to create polygons" problem as well since your startPoint remained as null in some browsers.

  5. #5
    Super Contributor
    Join Date
    May 2008
    Location
    Helsinki, Finland
    Posts
    1,100

    Re: Problem with mousedown/mouseup events

    Hi there,

    Good question indeed. This has resulted now in a bug report on the product side. I will update this thread when I get an update regarding.

    Please could you e-mail me as much as you want to reveal of the code, it would be of high value to the testing team?

    My e-mail is marko.lumivuori(at)nokia.com

    Thank you for your finding and feedback!

    Best Regards,
    Marko
    [FONT="Comic Sans MS"][COLOR="Blue"][/COLOR][I]Marko Lumivuori
    Technical Support
    +358 40 8019330
    [email]marko.lumivuori@nokia.com[/email][/I][/FONT]

Similar Threads

  1. Problem with key events in E5
    By anglina in forum Symbian
    Replies: 1
    Last Post: 2011-05-27, 10:16
  2. Flickable and MouseUp
    By alichino in forum [Archived] Qt Quick
    Replies: 3
    Last Post: 2011-03-13, 08:53
  3. Replies: 0
    Last Post: 2009-12-10, 14:15
  4. Replies: 2
    Last Post: 2009-01-21, 05:13
  5. Problem with key events
    By abha2100 in forum Mobile Java Games
    Replies: 2
    Last Post: 2007-11-02, 12:27

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •