Infrastructure Map Server Forum
Welcome to Autodesk’s Infrastructure Map Server Forums. Share your knowledge, ask questions, and explore popular Infrastructure Map Server topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using Wheel Button to Pan

9 REPLIES 9
Reply
Message 1 of 10
mistermike
2130 Views, 9 Replies

Using Wheel Button to Pan

How would I go about making it so that clicking the middle/wheel button on the mouse will enable the pan tool while the button is held down. (Like in AutoCAD, Map3D etc.)

Thanks,

-Mike
9 REPLIES 9
Message 2 of 10
jumpinjackie
in reply to: mistermike

Look for the OnMouseDown(e) and OnMouseUp(e) functions in ajaxmappane.templ

That's where all the action starts and ends.

- Jackie
http://themapguyde.blogspot.com
http://au.linkedin.com/in/jackieng
Message 3 of 10
mistermike
in reply to: mistermike

Thanks for the reply.
I found the OnMouseDown(e) and OnMouseUp(e) functions in ajaxmappane.templ, I'm just not sure what to do with them. 🙂 I'm still kind of new at this.

My Autodesk reseller is telling me it can't be done in the AJAX viewer (which is what I'm using, forgot to mention that). Does she know what she's talking about?

Thanks again,

-Mike
Message 4 of 10
jumpinjackie
in reply to: mistermike

I can't see why it could not be done.

You are basically reusing the pan behaviour which is already implemented in the AJAX viewer, you just now have to hook that behaviour to a middle mouse click and release.

Unfortuantely, I cannot show you how to implement it, because I haven't done it myself, but I do have a high-level knowledge of the internals of the AJAX viewer to tell you that such a thing is possible.

Also, resellers usually aren't programmers and/or technically minded 😉
http://themapguyde.blogspot.com
http://au.linkedin.com/in/jackieng
Message 5 of 10
Anonymous
in reply to: mistermike

wrote in ...



Jackie, you are starting to sound like Andrew D.
: )

We are trying.

--

Murph
The world is not FLAT so why is your GIS data?
http://map3d.wordpress.com
Message 6 of 10
nclayton
in reply to: mistermike

in the mousedown event, you have to check to see if it's the middle mouse button (these are different values for IE and FF...just google and you'll find this easy enough) then call the start pan function and on the mouseup, call the end pan function.
Message 7 of 10
david.roy
in reply to: mistermike

Hi all.  Was wondering if anyone had done this change successfully?  I'd really love to enable panning with mouse wheel.

 

many thanks

Message 8 of 10

Would also like to know the solution

 

thanks,

Message 9 of 10

Hello,

 

Firstly, Thanks Jackie for telling everyone where to look, this was pretty easy, and I'm not great at Javascript

 

I tackled this, and here is what I've got working...

Looks like the placement is everything to make sure you check for middle before left/ right

 

In ajamappane.templ....

 

in OnMouseDown(e) before the check for Left Button Click, check for Middle Mouse

function OnMouseDown(e)
{
    if(!PopupMouseDown(e))
    {
        hidePopup(tbMenu);
        hidePopup(ctxMenu);
        hidePopup(infoMenu);
        parent.ForwardMouseDown(document, e);
    }
    else
        return false;

    if(!mapInit)
        return false;
        
// NEW CODE BLOCK START HERE
    if(e.which && e.which == 2) //2 is middle button in W3C/Netscape Which
	StartPanning(e);
    else if(e.button && e.button == 4) //for ie, middle button is 4
        StartPanning(e);
// END CODE BLOCK HERE FOR MIDDLE Mouse PANNING
		
     if(e.which && e.which != 1)
        return true;
    else if(e.button && e.button != 1)//for ie
        return true;

 

 

 

Then in OnMouseUp(e)

 

function OnMouseUp(e)
{       
    var x = e.clientX - mapPosX;
    var y = e.clientY;
    try
    {
        e.stopPropagation();
    }
    catch(ex)
    {
        e.cancelBubble = true;
    }

// NEW CODE ADDED HERE, BEFORE DIGITIZATION CHECK
if(e.which && e.which == 2) //2 is middle button EndPanning(e); else if(e.button && e.button == 4)//for ie EndPanning(e); // END NEW CODE
if(digitizing) { digitizer.MouseUp(e, x, y); return false; } if(isAlertShow) return;

I didn't test it out with other redlining or digitizing continuous commands.. ie pan will digitizing, but for my needs, just panning with the middle button adds a tonne of user experience if other things break.

 

 

Message 10 of 10
david.roy
in reply to: mistermike

Perfect!  does the trick, thankyou for posting.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report