Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separation of Event Management from Window Base to a custom type #256

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions examples/Examples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SFML.Window", "..\src\SFML.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "netcore", "netcore\netcore.csproj", "{93B8425A-AC40-4486-96AF-20027B738C09}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "custom_eventman", "custom_eventman\custom_eventman.csproj", "{03A24BD1-B960-4E4A-AF8A-22BA8DA9BAFC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -183,6 +185,18 @@ Global
{93B8425A-AC40-4486-96AF-20027B738C09}.Release|x64.Build.0 = Release|Any CPU
{93B8425A-AC40-4486-96AF-20027B738C09}.Release|x86.ActiveCfg = Release|Any CPU
{93B8425A-AC40-4486-96AF-20027B738C09}.Release|x86.Build.0 = Release|Any CPU
{03A24BD1-B960-4E4A-AF8A-22BA8DA9BAFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03A24BD1-B960-4E4A-AF8A-22BA8DA9BAFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03A24BD1-B960-4E4A-AF8A-22BA8DA9BAFC}.Debug|x64.ActiveCfg = Debug|Any CPU
{03A24BD1-B960-4E4A-AF8A-22BA8DA9BAFC}.Debug|x64.Build.0 = Debug|Any CPU
{03A24BD1-B960-4E4A-AF8A-22BA8DA9BAFC}.Debug|x86.ActiveCfg = Debug|Any CPU
{03A24BD1-B960-4E4A-AF8A-22BA8DA9BAFC}.Debug|x86.Build.0 = Debug|Any CPU
{03A24BD1-B960-4E4A-AF8A-22BA8DA9BAFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03A24BD1-B960-4E4A-AF8A-22BA8DA9BAFC}.Release|Any CPU.Build.0 = Release|Any CPU
{03A24BD1-B960-4E4A-AF8A-22BA8DA9BAFC}.Release|x64.ActiveCfg = Release|Any CPU
{03A24BD1-B960-4E4A-AF8A-22BA8DA9BAFC}.Release|x64.Build.0 = Release|Any CPU
{03A24BD1-B960-4E4A-AF8A-22BA8DA9BAFC}.Release|x86.ActiveCfg = Release|Any CPU
{03A24BD1-B960-4E4A-AF8A-22BA8DA9BAFC}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
54 changes: 54 additions & 0 deletions examples/custom_eventman/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System.Collections.Generic;
using SFML.Graphics;
using SFML.Window;
namespace Program;

public struct SimpleEventPasser : IEventMan
{
private readonly List<Event> _events;
public SimpleEventPasser() => _events = new();
public void HandleEvent(Event eve)
{
switch (eve.Type)
{
case EventType.Closed:
case EventType.LostFocus:
case EventType.GainedFocus:
case EventType.KeyPressed:
case EventType.KeyReleased:
_events.Add(eve);
break;
default: // Filtering out all other events
break;
}
}
public void PrepareFrame() => _events.Clear();
public IEnumerable<Event> ProcessEvents() => _events;
}
public static class Program
{
public static void Main()
{
var event_man = new SimpleEventPasser();
var window = new RenderWindow(
new(640, 480),
"Custom Event Manager example",
Styles.Default,
event_man
);
while (window.IsOpen)
{
window.Clear(Color.Black);
window.DispatchEvents();
window.Display();
foreach (var e in event_man.ProcessEvents())
{
System.Console.WriteLine(e.ToString());
if (e.Type == EventType.Closed)
{
window.Close();
}
}
}
}
}
14 changes: 14 additions & 0 deletions examples/custom_eventman/custom_eventman.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<ProjectReference Include="..\..\src\SFML.Net\SFML.Net.csproj" />
</ItemGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion examples/netcore/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static void Main(string[] args)
var sound = new Sound(GenerateSineWave(frequency: 440.0, volume: .25, seconds: 1));

var window = new RenderWindow(new VideoMode(800, 600), "SFML running in .NET Core");
window.Closed += (_, __) => window.Close();
(window.SfmlEventManager as SubscribeManager).Closed += (_, __) => window.Close();

sound.Play();

Expand Down
7 changes: 4 additions & 3 deletions examples/opengl/OpenGL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ static void Main()
//GraphicsContext context = new GraphicsContext(new ContextHandle(IntPtr.Zero), null);

// Setup event handlers
window.Closed += new EventHandler(OnClosed);
window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
window.Resized += new EventHandler<SizeEventArgs>(OnResized);
var handler = window.SfmlEventManager as SubscribeManager;
handler.Closed += new EventHandler(OnClosed);
handler.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
handler.Resized += new EventHandler<SizeEventArgs>(OnResized);

// Create a sprite for the background
var background = new Sprite(new Texture("resources/background.jpg"));
Expand Down
5 changes: 3 additions & 2 deletions examples/shader/Shader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,9 @@ static void Main()
window.SetVerticalSyncEnabled(true);

// Setup event handlers
window.Closed += OnClosed;
window.KeyPressed += OnKeyPressed;
var handler = window.SfmlEventManager as SubscribeManager;
handler.Closed += OnClosed;
handler.KeyPressed += OnKeyPressed;

// Load the application font and pass it to the Effect class
var font = new Font("resources/sansation.ttf");
Expand Down
6 changes: 3 additions & 3 deletions examples/visualbasic/OpenGL.vb
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,15 @@
''' <summary>
''' Function called when the window is closed
''' </summary>
Sub App_Closed(ByVal sender As Object, ByVal e As EventArgs) Handles window.Closed
Sub App_Closed(ByVal sender As Object, ByVal e As EventArgs) Handles window.SfmlEventManager.Closed

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 180 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.
Dim window = CType(sender, RenderWindow)
window.Close()
End Sub

''' <summary>
''' Function called when a key is pressed
''' </summary>
Sub App_KeyPressed(ByVal sender As Object, ByVal e As KeyEventArgs) Handles window.KeyPressed
Sub App_KeyPressed(ByVal sender As Object, ByVal e As KeyEventArgs) Handles window.SfmlEventManager.KeyPressed

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 188 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.
Dim window = CType(sender, RenderWindow)
If e.Code = Keyboard.Key.Escape Then
window.Close()
Expand All @@ -195,7 +195,7 @@
''' <summary>
''' Function called when the window is resized
''' </summary>
Sub App_Resized(ByVal sender As Object, ByVal e As SizeEventArgs) Handles window.Resized
Sub App_Resized(ByVal sender As Object, ByVal e As SizeEventArgs) Handles window.SfmlEventManager.Resized

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Linux .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS ARM64 .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 7

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / macOS x64 .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 9

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 8

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.

Check failure on line 198 in examples/visualbasic/OpenGL.vb

View workflow job for this annotation

GitHub Actions / Windows .NET 6

'Handles' in modules must specify a 'WithEvents' variable qualified with a single identifier.
GL.Viewport(0, 0, e.Width, e.Height)
End Sub

Expand Down
2 changes: 1 addition & 1 deletion examples/window/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void Run()
{
var mode = new SFML.Window.VideoMode(800, 600);
var window = new SFML.Graphics.RenderWindow(mode, "SFML works!");
window.KeyPressed += Window_KeyPressed;
(window.SfmlEventManager as SFML.Window.SubscribeManager).KeyPressed += Window_KeyPressed;

var circle = new SFML.Graphics.CircleShape(100f)
{
Expand Down
25 changes: 15 additions & 10 deletions src/SFML.Graphics/RenderWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ public class RenderWindow : Window.Window, RenderTarget
/// </summary>
/// <param name="mode">Video mode to use</param>
/// <param name="title">Title of the window</param>
/// <param name="manager">A custom event manager. By default, a SubscribeManager object is created</param>
////////////////////////////////////////////////////////////
public RenderWindow(VideoMode mode, string title) :
this(mode, title, Styles.Default, new ContextSettings(0, 0))
public RenderWindow(VideoMode mode, string title, IEventMan manager = null) :
this(mode, title, Styles.Default, new ContextSettings(0, 0), manager)
{
}

Expand All @@ -34,9 +35,10 @@ public RenderWindow(VideoMode mode, string title) :
/// <param name="mode">Video mode to use</param>
/// <param name="title">Title of the window</param>
/// <param name="style">Window style (Resize | Close by default)</param>
/// <param name="manager">A custom event manager. By default, a SubscribeManager object is created</param>
////////////////////////////////////////////////////////////
public RenderWindow(VideoMode mode, string title, Styles style) :
this(mode, title, style, new ContextSettings(0, 0))
public RenderWindow(VideoMode mode, string title, Styles style, IEventMan manager = null) :
this(mode, title, style, new ContextSettings(0, 0), manager)
{
}

Expand All @@ -48,9 +50,10 @@ public RenderWindow(VideoMode mode, string title, Styles style) :
/// <param name="title">Title of the window</param>
/// <param name="style">Window style (Resize | Close by default)</param>
/// <param name="settings">Creation parameters</param>
/// <param name="manager">A custom event manager. By default, a SubscribeManager object is created</param>
////////////////////////////////////////////////////////////
public RenderWindow(VideoMode mode, string title, Styles style, ContextSettings settings) :
base(IntPtr.Zero, 0)
public RenderWindow(VideoMode mode, string title, Styles style, ContextSettings settings, IEventMan manager = null) :
base(manager, IntPtr.Zero)
{
// Copy the string to a null-terminated UTF-32 byte array
byte[] titleAsUtf32 = Encoding.UTF32.GetBytes(title + '\0');
Expand All @@ -70,9 +73,10 @@ public RenderWindow(VideoMode mode, string title, Styles style, ContextSettings
/// Create the window from an existing control with default creation settings
/// </summary>
/// <param name="handle">Platform-specific handle of the control</param>
/// <param name="manager">A custom event manager. By default, a SubscribeManager object is created</param>
////////////////////////////////////////////////////////////
public RenderWindow(IntPtr handle) :
this(handle, new ContextSettings(0, 0))
public RenderWindow(IntPtr handle, IEventMan manager = null) :
this(handle, new ContextSettings(0, 0), manager)
{
}

Expand All @@ -82,9 +86,10 @@ public RenderWindow(IntPtr handle) :
/// </summary>
/// <param name="handle">Platform-specific handle of the control</param>
/// <param name="settings">Creation parameters</param>
/// <param name="manager">A custom event manager. By default, a SubscribeManager object is created</param>
////////////////////////////////////////////////////////////
public RenderWindow(IntPtr handle, ContextSettings settings) :
base(sfRenderWindow_createFromHandle(handle, ref settings), 0)
public RenderWindow(IntPtr handle, ContextSettings settings, IEventMan manager = null) :
base(manager, sfRenderWindow_createFromHandle(handle, ref settings))
{
Initialize();
}
Expand Down
21 changes: 21 additions & 0 deletions src/SFML.Window/IEventMan.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace SFML.Window
{
/// <summary>An instance that manages events within a SFML.Window</summary>
public interface IEventMan
{

////////////////////////////////////////////////////////////
/// <summary>
/// This method is called by the window before
/// detecting the events from the new. Use for any
/// setup and cleanup of previous batch (if needed)
/// </summary>
////////////////////////////////////////////////////////////
void PrepareFrame();
////////////////////////////////////////////////////////////
/// <summary>Handles the event which was passed to it by the Window class</summary>
/// <param name="eve">The event object recieved</param>
////////////////////////////////////////////////////////////
void HandleEvent(Event eve);
}
}
Loading
Loading