How to add mouse event?

Jul 13, 2010 at 10:17 AM

Hi I download your GettnigStarted project. And I want to add a first person camera. But I don't how to add a mouse event. Do you have any example code that could be download? I download the SimpleBrowser but seems the code is not the newest one....

Coordinator
Jul 13, 2010 at 10:26 AM

Hi,

I'm afraid the GettingStarted project is a bit obsolete - not being maintained, in fact I'll probably remove it. If you look at the SampleBrowser, there is a Mouse event sample there with Source Code in the browser in the Source tab.

 

Jul 13, 2010 at 10:32 AM
Edited Jul 14, 2010 at 1:39 AM

thanks for your replay. But http://dl.dropbox.com/u/5342359/Balder/SampleBrowser/TestPage.html throws an error(I could open it last week):

The requested URL could not be retrieved

I don't know why.

 

Does "Game" class has an event handler that could simply add a event on it?

Does the code below could be worked?

 

void MainPage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)

        {
            Point p = e.GetPosition(MyGame);	
            
        }

------------------------------------------------------------

class MyGame : Game

Coordinator
Jul 13, 2010 at 10:45 AM

Odd you're getting that URL error. 

Anyways, Mouse events are very simple, on any Geometry you have MouseEnter, MouseLeave, MouseMove, MouseLeftButtonUp, MouseLeftButtonDown events. Simply add an event handler to any of your geometry, and you're set to go.

But, keep in mind; the MouseEventArgs is not the same as in Silverlight. The reason its not the same is that Balder needs to handle mouse events itself, since everything is software rendered and Microsoft has sealed the MouseEventArgs class and made the constructor internal to Silverlight, so one can not create instances of it. Therefor Balder has its own representation of it.

 

Jul 13, 2010 at 1:33 PM

Thanks man, finally I get the reason why I couldn't find the mouse move event...I didn't use the newest code...

But I still suggest you guys could create a default first person browse camera....you know that this is important for debuging