Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: windows cants receive any events  (Read 1085 times)

0 Members and 1 Guest are viewing this topic.

Pulp_Fiction98

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
windows cants receive any events
« on: March 05, 2025, 09:34:32 am »
System: windows。
I used. net to create a win32 handle in Avalonia, then created a window using SFML and embedded it into the Avalonia form. The rendering and drawing are all normal, but the SFML form cannot receive any events. Is there anything that needs to be set?

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
         
            this.Loaded += MainWindow_Loaded;  
        }

        private void MainWindow_Loaded(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
        {
         
            var window = new SFML.Graphics.RenderWindow(windowBox.Handle);
            // window.KeyPressed += Window_KeyPressed;
            window.MouseMoved += Window_MouseMoved; ;
             var circle = new SFML.Graphics.CircleShape(100f)
            {
                FillColor = SFML.Graphics.Color.Blue,
                Position=new Vector2f(500,500)
            };
            window.Draw(circle);

            // Finally, display the rendered frame on screen
            window.Display();
       
        }

        private void Window_MouseMoved(object? sender, SFML.Window.MouseMoveEventArgs e)
        {
           //Can In it
        }
    }
    public class NativeEmbeddingControl : NativeControlHost
    {
        public IntPtr Handle { get; private set; }

        protected override IPlatformHandle CreateNativeControlCore(IPlatformHandle parent)
        {

            var handle = base.CreateNativeControlCore(parent);
            Handle = handle.Handle;
            Console.WriteLine($"Handle : {Handle}");
            return handle;
        }
    }
« Last Edit: March 05, 2025, 12:35:02 pm by eXpl0it3r »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11173
    • View Profile
    • development blog
    • Email
Re: windows cants receive any events
« Reply #1 on: March 10, 2025, 08:55:09 am »
I don't see you calling window.DispatchEvents(); have you just forgotten to do so, or is it not shown in the provided code?

There might still be some trouble if you intend to share events between Avalonia and SFML, that one will consume all the events of the other.
Official FAQ: https://www.sfml-dev.org/faq/
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything