SFML community forums

Help => Window => Topic started by: farooqaaa on August 16, 2013, 03:37:34 am

Title: Window does not activate if you click inside it
Post by: farooqaaa on August 16, 2013, 03:37:34 am
Does anyone have this problem? Here's a gif that shows I am talking about:

http://i.imgur.com/dcTZyTG.gif (http://i.imgur.com/dcTZyTG.gif)
(http://i.imgur.com/dcTZyTG.gif)
Title: Re: Window does not activate if you click inside it
Post by: OniLinkPlus on August 16, 2013, 04:14:45 am
https://github.com/SFML/SFML/issues/437 I think this is the issue you are talking about. It was introduced by accident in 2.1, and will hopefully be fixed in 2.2.
Title: Re: Window does not activate if you click inside it
Post by: JuDelCo on September 14, 2013, 12:17:44 am
Same here (I'm using v2.1 too)

I'll wait for the 2.2 release then ^^
Title: Re: Window does not activate if you click inside it
Post by: eXpl0it3r on September 14, 2013, 12:20:41 am
Does anyone have this problem?
The search is usually very good at answering such questions. ;)
Title: Re: Window does not activate if you click inside it
Post by: Vicker on September 16, 2013, 07:52:54 am
Does anyone have this problem?
The search is usually very good at answering such questions. ;)

I'm glad he posted this.  I'm having the same problem, and stumbled upon this post while looking for a solution.

I'd like to chime in that this is a major problem for my implementation.  I'm mixing SFML with a GTK+, with one SFML window and one GTK+ controlled window, and the player needs to be able to switch back and forth between them in a non-convoluted manner.
Title: AW: Re: Window does not activate if you click inside it
Post by: eXpl0it3r on September 16, 2013, 11:24:13 am
I'm glad he posted this.  I'm having the same problem, and stumbled upon this post while looking for a solution.
There are at least 3 other threads about this bug... ;)

I'd like to chime in that this is a major problem for my implementation.  I'm mixing SFML with a GTK+, with one SFML window and one GTK+ controlled window, and the player needs to be able to switch back and forth between them in a non-convoluted manner.
Well it's a bug and it will get addressed, most likely for the next version of SFML. Currently you can either down grade to SFML 2.0 or revert the breaking change in your own SFML version or find a fix for it - unfortunately there doesn't seem to be one (check out the issue on the issue tracker).
Title: Re: Window does not activate if you click inside it
Post by: Laurent on September 16, 2013, 11:51:07 am
There is a pull request waiting to be merged, that fixes this bug.
Title: Re: AW: Re: Window does not activate if you click inside it
Post by: Vicker on September 16, 2013, 03:13:06 pm
Well it's a bug and it will get addressed, most likely for the next version of SFML. Currently you can either down grade to SFML 2.0 or revert the breaking change in your own SFML version or find a fix for it - unfortunately there doesn't seem to be one (check out the issue on the issue tracker).

Oh, I'm not in a huge rush.  It'll be quite a while before I work out the other kinks in this goofy idea of mine, so hopefully it'll be fixed by then.  I'm glad to hear that it's getting fixed.
Title: Re: Window does not activate if you click inside it
Post by: Demir on September 17, 2013, 09:23:56 am
I think "On-Screen Keyboard" programs need this property (bug) . :)

can it be useful for this purpose?
Title: Re: Window does not activate if you click inside it
Post by: Hapax on February 02, 2014, 08:19:37 pm
I'm sorry for resurrecting an old thread; I believe it's still relevant, however, as the problem still exists. (I'm aware that this is being fixed in the library)

I ended up on this thread because I was having this problem too. I came back because I found a simple workaround. It may be bad practice but it seems to work until the fix is applied.

This is for Windows only. You'll also need to
#include <Windows.h>

If, in your main loop, you put the code:
SetForegroundWindow(renderWindow.getSystemHandle());
with "renderWindow" being your RenderWindow object, it should allow you to click the client area to refocus the window. Oddly, it doesn't actually set the focus of the window or activate it by itself as it is supposed to.

I hope this helps for now. I'm looking forward to the new version of SFML (hopefully with a VS2013 build as my build seemed to fail at creating debug libraries :( )
Title: Re: Window does not activate if you click inside it
Post by: zsbzsb on February 02, 2014, 08:45:41 pm
And I don't know how many other times this has been stated around the forums.... it has been fixed for months already in the github source code.
Title: Re: Window does not activate if you click inside it
Post by: Hapax on February 02, 2014, 09:14:32 pm
But not in the current release?
I'm new and I've been using C++ and SFML for only a few days after I had to build it from the source code myself. I found that this workaround temporarily fixes the problem until the latest version has the proper fix.

That said, I have no idea what github is.
Title: Re: Window does not activate if you click inside it
Post by: dabbertorres on February 02, 2014, 10:14:55 pm
That said, I have no idea what github is.
Github (https://github.com/about) is a beautiful place.

SFML's Github page (https://github.com/SFML/SFML)
Title: Re: Window does not activate if you click inside it
Post by: AN71 on February 03, 2014, 06:18:09 am
That said, I have no idea what github is.
Github (https://github.com/about) is a beautiful place.


Agreed, but to elaborate (at least in layman's terms) Github is a place for people to host source code based on the Git SCM system. People can write commits, and share ideas, it is one of the quintessential pieces of Open Source in my opinion. However, I suppose they still do have private repositories. There is still a lot more to it, though I don't believe its really necessary to cover it all. ;)
edit:Disclaimer: Although I'm pretty new to SFML, I've used Github for a while
Title: Re: Window does not activate if you click inside it
Post by: Moberg on February 11, 2014, 12:46:09 pm
This is not fixed yet. Why isn't there a new release? Or some info/guide about this on the download site?

Quickest way to fix?
Title: Re: Window does not activate if you click inside it
Post by: eXpl0it3r on February 11, 2014, 01:13:47 pm
It is fixed in the source code. There will be a new release when Laurent decides to do so.

If you want it to have fixed, build from source (https://github.com/SFML/SFML). :)
Title: Re: Window does not activate if you click inside it
Post by: Hapax on February 11, 2014, 03:12:27 pm
This is not fixed yet. Why isn't there a new release? Or some info/guide about this on the download site?

Quickest way to fix?
Look at my post above if you need a temporary workaround (assuming it's for Windows) to make it convenient for yourself during testing.
That said, you should probably build from the Github source if you want it to be fixed internally. I'd do it too if I didn't have enough problems building the released version last time. Me and my using stupid VS2013  >:(
Title: Re: Window does not activate if you click inside it
Post by: Vicker on December 18, 2014, 09:45:22 am
I was really excited to see 2.2 released today.  Now I'm really disappointed that this issue was not fixed in 2.2.  What gives?
Title: AW: Re: SFML 2.2 Released!
Post by: eXpl0it3r on December 18, 2014, 12:26:35 pm
It is fixed, has been in source code for a long, long time. ;)

Make sure to remove old SFML libraries and make a clean rebuild.
Title: Re: AW: Re: SFML 2.2 Released!
Post by: Vicker on December 18, 2014, 10:38:44 pm
It is fixed, has been in source code for a long, long time. ;)

Make sure to remove old SFML libraries and make a clean rebuild.

I did. 

I'm using Code Blocks.  I downloaded the GCC 4.9.2 MinGW (DW2) - 32-bit version.  I changed the search directories for the compiler and linker to the new 2.2 folder.  I also deleted the folders containing older versions just to be sure.
Title: Re: Window does not activate if you click inside it
Post by: eXpl0it3r on December 18, 2014, 11:04:42 pm
Works like a charm here.

Are you should you did a full & clean rebuild?

(https://i.imgur.com/i42CGTq.png)
Title: Re: Window does not activate if you click inside it
Post by: Vicker on December 19, 2014, 06:59:50 am
Works like a charm here.

Are you should you did a full & clean rebuild?

(https://i.imgur.com/i42CGTq.png)

Yes, I did a full rebuild, with the rebuild button.  Still no luck.

Should I mention that the other windows are GTK+?  They seem to behave correctly.  It's only the SFML window that's not working correctly.  When I click on the body of the SFML window, all windows lose focus, as though I had clicked empty space on the desktop.  I didn't have this problem back when I was using SFML 1.6. 

Edit: Just for fun, I tried using the "GCC 4.7.1 TDM (SJLJ) - 32-bit" instead of the "GCC 4.9.2 MinGW (DW2) - 32-bit" version of SFML.  Still didn't help.  I suppose I could try building SFML myself, I guess...
Title: Re: Window does not activate if you click inside it
Post by: eXpl0it3r on December 19, 2014, 09:28:52 am
So you're mixing SFML with your own GTK+ windows?

What if you just used like the simplest example:

#include <SFML/Graphics.hpp>

int main()
{
        sf::RenderWindow window{{1024, 768}, "Test"};

        while(window.isOpen())
        {
                sf::Event event;
                while(window.pollEvent(event))
                {
                        if(event.type == sf::Event::Closed)
                                window.close();
                }

                window.clear();
                window.display();
        }
}
 
Title: Re: Window does not activate if you click inside it
Post by: Vicker on December 19, 2014, 01:00:50 pm
So you're mixing SFML with your own GTK+ windows?

What if you just used like the simplest example:

#include <SFML/Graphics.hpp>

int main()
{
        sf::RenderWindow window{{1024, 768}, "Test"};

        while(window.isOpen())
        {
                sf::Event event;
                while(window.pollEvent(event))
                {
                        if(event.type == sf::Event::Closed)
                                window.close();
                }

                window.clear();
                window.display();
        }
}
 

I just tried your simple example.  When I ran the code exactly as you have it, I got an error about extended initializer lists being only available with -std=c++11.  I modified the sf::RenderWindow line to instead read:

sf::RenderWindow window(sf::VideoMode(800, 600), "My window");

as per the tutorial page on using the SFML graphics package.  This modification makes the simple example run correctly.  However, the window still suffers from the same problem as before.  The window does not regain focus by clicking in the body of the window.
Title: Re: Window does not activate if you click inside it
Post by: eXpl0it3r on December 19, 2014, 01:39:26 pm
I know, I probably get rather annoying by now, but the fact that I know it got fixed and that I (and probably nobody else) can't reproduce it, still makes me question whether you're using the new libraries...
Can you download a SFML 2.2 package (http://www.sfml-dev.org/download/sfml/2.2/) again and run some of the examples that come with it. Does it happen with them as well? If not you must still somehow be using the old libraries (make sure you've changed the settings for debug and release).
Title: Re: Window does not activate if you click inside it
Post by: Vicker on December 19, 2014, 11:57:02 pm
I know, I probably get rather annoying by now, but the fact that I know it got fixed and that I (and probably nobody else) can't reproduce it, still makes me question whether you're using the new libraries...
Can you download a SFML 2.2 package (http://www.sfml-dev.org/download/sfml/2.2/) again and run some of the examples that come with it. Does it happen with them as well? If not you must still somehow be using the old libraries (make sure you've changed the settings for debug and release).

I fixed it.  Now I feel like an idiot.  I had updated all the linking in the compiler but I still needed to update the .dll files. 

Thanks for putting up with my silliness and helping me to get this working!  I'm excited to have it working now!