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

Author Topic: Title bar display and closing problem  (Read 2674 times)

0 Members and 1 Guest are viewing this topic.

JLesage

  • Newbie
  • *
  • Posts: 7
    • View Profile
Title bar display and closing problem
« 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;
}

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Title bar display and closing problem
« Reply #1 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
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Title bar display and closing problem
« Reply #2 on: May 09, 2023, 01:36:18 pm »
Does using sf::Style::Titlebar | sf::Style::Close work?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Title bar display and closing problem
« Reply #3 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).
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Title bar display and closing problem
« Reply #4 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 :)
« Last Edit: May 12, 2023, 12:06:39 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Title bar display and closing problem
« Reply #5 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
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything