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

Author Topic: Can't access requestFocus function  (Read 4499 times)

0 Members and 2 Guests are viewing this topic.

cocr1742

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Can't access requestFocus function
« on: September 22, 2017, 02:07:43 am »
This is my first project working with sfml and I'm creating a full screen program on a Raspberry Pi 3 that captures keyboard input and tracks the outcome of a board game. I noticed that occasionally my fullscreen renderwindow will "freeze"- not accept input from keyboard, as well as stopping a rotating set of 4 graphics in one area - and the only way to exit is to kill the program from the command line. Reading more into it, I think I realized that it has to do with my window losing focus. I've researched in depth and found the requestFocus function which I'm hoping will fix my problem- along with some hasFocus booleans - but when I went to implement this, apparently the requestFocus function doesn't exist.

Sf::RenderWindow window;
window.requestFocus();

When I try to compile, it says class sf::RenderWindow has no member named 'requestFocus'. I've tried it with just a Window class as well.

This is honestly one of my first full projects, so it might be a stupid question/simple fix like a #include that I missed or something, but I can't find anything about why this isn't working for me. Anyone got any ideas or workarounds?
Here's my heading:

#include <SFML/Graphics.hpp>
#include <iostream>
#include <cstdio>
#include <cstdlib>

Thanks

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: Can't access requestFocus function
« Reply #1 on: September 22, 2017, 02:21:40 am »
What SFML version are you running?
If requestFocus() can't be found then you must be running like SFML 2.1 which is very old.

Solution then would be to build from source or find an updated package.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

cocr1742

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Can't access requestFocus function
« Reply #2 on: September 22, 2017, 02:30:24 am »
What SFML version are you running?
If requestFocus() can't be found then you must be running like SFML 2.1 which is very old.

Solution then would be to build from source or find an updated package.

I was worried that might be what it was, is it possible to update it easily without having to rewrite my program?

Thanks for the response. I'll start googling how to do that. Again, I'm pretty new to this haha

cocr1742

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Can't access requestFocus function
« Reply #3 on: September 22, 2017, 02:35:18 am »
So I did an general update to my system, as well as $ sudo apt-get install libsfml-dev    which is what the sfml tutorial has to install it first, and it says that libsfml-dev is already the newest version with 0 upgraded packages. Should I be doing this a different way?

Thanks again

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Can't access requestFocus function
« Reply #4 on: September 22, 2017, 06:28:50 am »
Official repositories may provide an old version, you'd better compile the latest version yourself from source.
Laurent Gomila - SFML developer

cocr1742

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Can't access requestFocus function
« Reply #5 on: September 22, 2017, 08:11:41 pm »
As I am running a 32-bit linux OS, is there a simpler way to do this than the tutorial lays out? Going by that I have to build it manually and I will almost positively screw that up haha. From the https://www.sfml-dev.org/download/sfml/2.4.0/    can I download the source code from the "All" section and compile/build it with a flag for 32 bit? Something like -DCMAKE_CXX_FLAGS=-m32?

This is not a very in depth project, I can't imagine needing any extra functionality than I already have except for being able to requestFocus...if there's a way to just inject that, that would work too.

cocr1742

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Can't access requestFocus function
« Reply #6 on: September 22, 2017, 08:16:12 pm »
Ah was going through the changelog and found https://www.sfml-dev.org/download/sfml/2.3.2/  which does have a 32-bit linux installer, and since requestFocus was added as part of 2.2, 2.3.2 should satisfy all my needs. Thanks!

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Can't access requestFocus function
« Reply #7 on: September 22, 2017, 08:22:55 pm »
On Linux you should be able to just git clone the repo, do ccmake (not ccmake is the command line program with a textual interface) and then make and make install, all out of a terminal. You might need to install -dev, -devel or whatever your repo calls them versions of some packages when they will be reported as missing, there is a list in all of the tutorials and the errors will say if it's xcb, jpeg, etc.
Back to C++ gamedev with SFML in May 2023

cocr1742

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Can't access requestFocus function
« Reply #8 on: September 22, 2017, 11:47:32 pm »
I've downloaded 2.3.2 and the auto-suggested requestFocus function comes up, however when I compile it, it still is giving the same error: that class sf::RenderWindow has no member named 'requestFocus'. I originally used apt-get install libsfml-dev to start working in sfml, could this outdated package still being integrated be the cause?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: Can't access requestFocus function
« Reply #9 on: September 22, 2017, 11:50:40 pm »
Uninstall all traces of SFML first, otherwise you'll end up with using the old binaries.
Also you can't use the Linux download provided on the download page for your Raspberry Pi. Those binaries are x64 and you need ARM and the two distros are quite different overall, so they probably wouldn't be compatible anyways.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

cocr1742

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Can't access requestFocus function
« Reply #10 on: September 25, 2017, 06:10:14 pm »
Uninstall all traces of SFML first, otherwise you'll end up with using the old binaries.
Also you can't use the Linux download provided on the download page for your Raspberry Pi. Those binaries are x64 and you need ARM and the two distros are quite different overall, so they probably wouldn't be compatible anyways.

I haven't uninstalled the old SFML first, I'll try that (should I use a remove or a purge?)

On the link I provided, there was a x32 download, and that was the one I used. If that's still not going to be compatible, and only the outdated released package is going to be compatible, then I'll need a work around using the outdated version that would accomplish the same request to OS to get focus. Does anyone know a good work around for this or where I could start/find one?

Thanks