SFML community forums

Help => Window => Topic started by: JLesage on May 06, 2023, 02:05:05 pm

Title: Title bar display and closing problem
Post by: JLesage on May 06, 2023, 02:05:05 pm
I'm a beginner in C++ and SFML for game creation under linux(Pop!_OS 22.04 LTS). I tested the code on the official SFML website, everything seems to work but the title bar doesn't display; it's the same with other codes. I need your help, please. Here is an example of a code I tested:
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>
 
 
int main()
{
    sf::RenderWindow window(sf::VideoMode(640, 480), "SFML works!", sf::Style::Titlebar);
    sf::Event ev;
 
    while(window.isOpen()){
       
        while(window.pollEvent(ev)){
 
            switch(ev.type){
                case sf::Event::Closed:
                    window.close();
                    break;
                case sf::Event::KeyPressed:
                    if(ev.key.code == sf::Keyboard::Escape){
                        window.close();
                        break;
                    }
                default:
                    break;
            }
             
        }
 
        //Render
        window.clear(sf::Color::Blue);
        window.display();
    }
 
    return 0;
}
Title: Re: Title bar display and closing problem
Post by: Hapax on May 08, 2023, 08:52:01 pm
I can't test for Linux for you but it seems to work fine for Windows.

That said, why would you not want a close button? :p
Title: Re: Title bar display and closing problem
Post by: eXpl0it3r on May 09, 2023, 01:36:18 pm
Does using sf::Style::Titlebar | sf::Style::Close work?
Title: Re: Title bar display and closing problem
Post by: Hapax on May 10, 2023, 05:31:14 pm
I've just noticed that if you do sf::Style::Titlebar | sf::Style::Resize then a resize control isn't given since none of those controls are given unless sf::Style::Close is included (or sf::Style::Default, of course).
This is Windows 11, by the way. Tested on both 2.6.x and 3- (master branch).
Title: Re: Title bar display and closing problem
Post by: eXpl0it3r on May 12, 2023, 12:03:58 am
Resize just means that the window can be resized, don't think we make any guarantees on the buttons :)
Title: Re: Title bar display and closing problem
Post by: Hapax on May 15, 2023, 08:51:14 pm
Ah, yes, of course! :-[

It does change the usability of the button when the button is provided, which is good, but we need to use Close to get our buttons! ;D