About Monkey 2 › Forums › Monkey 2 Programming Help › Mouse Desktop Issue?
Tagged: Desktop., Mouse Test
This topic contains 3 replies, has 2 voices, and was last updated by
Mark Sibly
2 years, 4 months ago.
-
AuthorPosts
-
December 8, 2016 at 10:21 am #5653
Hello Mark,
This Mouse test displays the mouse coodinate on the screen.
When I build it for Desktop it does not update, but it runs fine when I build it for Emscriten and for Android too.[/crayon]Monkey123[crayon-5cba95bb22464737826543 inline="true" ]#Import ""#Import ""Using std..
Using mojo..Class MyWindow Extends Window
Field x:Int
Field y:Int
Field lb:Int,rb:Int, md:Int
<p style=”padding-left: 30px;”>Method OnRender( canvas:Canvas ) Override
x=Mouse.X
y=Mouse.Y
lb=Mouse.ButtonDown(MouseButton.Left)
rb=Mouse.ButtonDown(MouseButton.Right)</p>
<p style=”padding-left: 60px;”>canvas.DrawText( “Mouse Test”,Width/2,Height/2,.5,.5 )
canvas.DrawText( “x:”+ x + ” y:” + y,Width/2,Height*.3,.5,.5 )
canvas.DrawText( “left button:”+lb+” right button”+rb ,Width/2,Height*.4,.5,.5 )</p>
<p style=”padding-left: 30px;”>End</p>
EndFunction Main()
New AppInstance
New MyWindow
App.Run()
EndDecember 18, 2016 at 11:40 pm #5895The desktop version needs ‘RequestRender’ somewhere, either in a timer or you can just stick it at the top of OnRender, eg:
Monkey1234Method OnRender( canvas:Canvas ) OverrideRequestRender()...blah...EndEmscripten works a little differently and is ‘always rendering’.
December 19, 2016 at 8:53 pm #5923Hello Mark,
Thank you that works. Below is the updated code.
Monkey12345678910111213141516171819202122232425262728293031323334353637383940#Import "<std>"#Import "<mojo>"#Import "<mojox>"Using std..Using mojo..Using mojox..Class MyWindow Extends WindowField x:IntField y:IntField lb:Int,rb:Int, md:IntMethod OnRender( canvas:Canvas ) OverrideRequestRender()x=Mouse.Xy=Mouse.Ylb=Mouse.ButtonDown(MouseButton.Left)rb=Mouse.ButtonDown(MouseButton.Right)canvas.DrawText( "Mouse Test",Width/2,Height/2,.5,.5 )canvas.DrawText( "x:"+ x + " y:" + y,Width/2,Height*.3,.5,.5 )End' Method OnMouseEvent( event:MouseEvent ) Override' Print event.Location' EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndDecember 19, 2016 at 9:05 pm #5924Also, emscripten should be working again with last master branch!
The emscripten compilers appear to have problems with long ‘relative’ paths (this has popped up a few times in the past too ), so I’ve made a few tweaks that should help – they do here anyway.
-
AuthorPosts
You must be logged in to reply to this topic.