Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Bindings - other languages
»
DotNet
»
Tutorial for 1.6 uses GetEvent, method is protected in API
Print
Pages: [
1
]
Author
Topic: Tutorial for 1.6 uses GetEvent, method is protected in API (Read 2786 times)
0 Members and 1 Guest are viewing this topic.
lightstar
Newbie
Posts: 2
Tutorial for 1.6 uses GetEvent, method is protected in API
«
on:
March 26, 2012, 04:51:47 pm »
I've been looking at some of the examples, and putting together a skeleton application. I'm using version 1.6 of the .NET bindings.
In this page:
http://www.sfml-dev.org/tutorials/1.6/window-events.php
the events are handled with GetEvent in the loop:
sf
::
Event
Event
;
while
(
App.
GetEvent
(
Event
)
)
{
// Window closed
if
(
Event.
Type
==
sf
::
Event
::
Closed
)
Running
=
false
;
}
but the sample code, see
https://github.com/SFML/SFML.Net/blob/master/examples/window/Window.cs
uses DispatchEvents as GetEvent is protected now.
Is the tutorial just out of date? What is the recommended method?
Also, the event handlers such as:
static
void
OnClosed
(
object
sender, EventArgs e
)
{
Window window
=
(
Window
)
sender
;
window
.
Close
(
)
;
}
require a cast on the sender. Is there no way to avoid this side-stepping the type system?
«
Last Edit: March 28, 2012, 12:49:53 pm by Laurent
»
Logged
Laurent
Administrator
Hero Member
Posts: 32498
Re: Tutorial for 1.6 uses GetEvent, method is protected in API
«
Reply #1 on:
March 26, 2012, 05:02:39 pm »
The tutorial is for C++, the /Net APi is slightly different -- that's why there are examples and an API doc.
The cast is required, this is the standard way of writing event handlers (ie. taking an Object argument instead of a typed one).
Logged
Laurent Gomila - SFML developer
lightstar
Newbie
Posts: 2
Re: Tutorial for 1.6 uses GetEvent, method is protected in API
«
Reply #2 on:
March 28, 2012, 12:42:50 pm »
Great, thanks for the reply. I am up and running now.
Logged
Print
Pages: [
1
]
SFML community forums
»
Bindings - other languages
»
DotNet
»
Tutorial for 1.6 uses GetEvent, method is protected in API
anything