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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - lehoangan02

Pages: [1]
1
Hello, I'm trying to build a SFML app (dictionary app)
I'm encountering an issue where my SFML window loses focus on startup, leading to unexpected behavior with mouse interactions.
Details:
  • Platform: macOS (apple silicon)
  • SFML version: 2.6.1
  • Behavior: The render window doesn't have focus. Some elements in the SFML window require double-clicking to respond, even though they are designed to work with a single-click. However, it is unable to regain focus when being clicked on (some how still able to poll double-click as two separate single-click event.) Also, the loading screen doesn't draw during startup, the drawLoadingScreen function only works after startup.
  • Cause: This seems to happen if I click on the program icon in my dock while it's starting up (there is a heavy function call before the event loop). The SFML window appears to lose focus but still registers a double-click as two separate single-click events. Despite this, clicking the SFML window itself does not restore focus.
  • Conditions: The problem is particularly noticeable when auto-save is enabled and the last save (serialized data) is large.
  • Temporary workaround: Switching to another program and then switching back to the SFML window restores the expected behavior.
Why is this happening? I never touch the sf::Event on LostFocus and GainFocus. I recheck my code and other than that it works fine.
Here is the relevant part of my code.
void instance::operatePage1()
{
        if (!loadedSave)
        {
                deleteWholeTrie(pRoot);
                drawLoadingPage(); /* this is supposed to draw the loading page but it doesn't */
                deserializeBinaryWrapper(pRoot); /* this is very slow and allow me to click on the executable`s icon in the dock during it`s startup */
                loadedSave = true;
        }
        while (windowInstance.pollEvent(event))
        {
                switch (event.type)
                {
                        case sf::Event::Closed:
                        {
                                windowInstance.close();
                        }
                        case sf::Event::MouseButtonPressed:
                        {
This is the loading page function
void instance::drawLoadingPage()
{
        windowInstance.clear();
        windowInstance.draw(loadingSprite);
        windowInstance.display();
}

Pages: [1]