how can i made a Drop down list in SFML ?

how can i made a Drop down list in SFML ?
Please help me , this drop down list contains names of different animals , i need a code ! Please
closed account (3qX21hU5)
What do you have so far? SFML isn't really made specifically for making GUI's so it won't be as easy as a library like QT or wxWidgets but it is still possible.

If you can post what you have so far and any problems you are having (Be specific) we would be more then willing to help out with this. Remember though the more detailed you are about your problems that you are having the more detailed help we can give.
you can either use or take ideas from the sfGUI or TGUI frameworks that implements GUIs.
http://sfgui.sfml-dev.de/
http://tgui.eu/
(Both are open source)
Last edited on
Zereo i am a student and given a small but complex project, i have to make a drop down list which contains animal names , and there is a speak button , when any one selects a particular animal name from drop down list and press speak button , then voice of that particular animal will be played ... :( ... this is all i have to do , please help , :( !
closed account (3qX21hU5)
Again the more information we have the more we can help. I understand the project that you are asked to do but I don't know what you are having trouble with exactly. If you can answer that it would be much easier to help you.

I would also like to say I won't do the project for you and I won't post code for you without seeing you have put a effort into doing this yourself. With that said though I am more then willing to help walk you through anything you don't understand or are having trouble with. I just need more information though. Short explanations get short answers.

Some other questions I have are

Do you have to use SFML for this project?

Are you able to use other libraries like SFGUI (I am assuming no because it is a assignment)?

If it is the overall project that you are having trouble with and don't know where to start then it helps to break it down into pieces.

Here is some very broad steps.

1) Get the window up and running

2) Get the drop down rectangle sprites up and going.

3) Add in your text to them rectangles

4) Implement the features to highlight text when the cursor hovers over a item, selects a item that is clicked and makes it the current selection and all that good stuff.

5) Start to implement a scrolling features using sf::View.

6) Start to link the sound files to each selection so that they play when the play button is pressed.

7) Add in all your extra features you want.
1) Yes i have to use SFML for this project
2)Yes i am able to use SFGUI

i have Set window up and it is running , :) , (step number 1 is done) , now how can i create button ?
and a drop down list ????


(zereo i m trying my level best to do this , i am giving daily 3 4 fours to this project, i am finding problems because i have no good know how about SFML, help me in creating button and drop down list !)
closed account (3qX21hU5)
2)Yes i am able to use SFGUI


I would recommend you use SFGUI or http://tgui.eu/ or another library like it with SFML since it will make your life much easier.

Just follow along with their tutorials and you should be fine. Here is some links that should help you out with this project.

getting started with tgui - http://tgui.eu/tutorials/v06/intro1/

About config files for widgets - http://tgui.eu/tutorials/v06/config-files/

listbox stuff - http://tgui.weebly.com/v05---listbox.html

button stuff - http://tgui.weebly.com/v05---button.html

callbacks(User interaction) - http://tgui.eu/tutorials/v06/intro3/

There are other tutorials that will help also.

TGUI seems easier to start out with then SFGUI so I would start out with that but it is up to you.

Last edited on
thanks , .. if i may cause a problem ., i will ask you ! :)
#include <SFML/window.hpp>
#include <SFML/system.hpp>
#include <SFML/audio.hpp>
#include <SFML/graphics.hpp>
//#include <SFML/Video.hpp>
#include <conio.h>
#include <TGUI/TGUI.hpp>
#include <iostream>


int main()
{
// Create the window
sf::RenderWindow window(sf::VideoMode(800, 600), "Window");
tgui::Gui gui(window);

// Load the font (you should check the return value to make sure that it is loaded)
gui.setGlobalFont("C:/Users/corleone/Downloads/Compressed/TGUI-0.6-alpha2-Visual-C++10-2010-32-bits/TGUI-0.6-alpha2/fonts/DejaVuSans.ttf");

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

// Pass the event to all the widgets (if there would be widgets)
gui.handleEvent(event);
}

window.clear();

// Draw all created widgets
gui.draw();

window.display();
}

return EXIT_SUCCESS;
}

zereo i am using this code ... and compiling it in both "release and debug solution configuration" .. it is giving an error ..i.e. "projecT.exe" is stop working .. but window is opening properly, but it is still giving that error .. i took this code from the link u gave me http://tgui.eu/tutorials/v06/intro1/ !



The "program has stopped working" can be caused if libraries aren't compatible with each other.
Make sure that when building in debug mode you link to the debug libs of both sfml and tgui (with '-d' suffix), and when compiling in release mode that you are linking to the release libs of both sfml and tgui.
Also make sure that you are linking both statically or both dynamically (with or without '-s' suffix), you can't combine it.

You can always ask questions on the tgui forum ( http://forum.tgui.eu ) as well if you get stuck.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <SFML/window.hpp>
#include <SFML/system.hpp>
#include <SFML/audio.hpp>
#include <SFML/graphics.hpp>
//#include <SFML/Video.hpp>
#include <conio.h>
#include <TGUI/TGUI.hpp>
#include <iostream>


int main()
{
// Create the window
sf::RenderWindow window(sf::VideoMode(800, 600), "Window");
tgui::Gui gui(window);

// Load the font (you should check the return value to make sure that it is loaded)
gui.setGlobalFont("C:/Users/corleone/Downloads/Compressed/TGUI-0.6-alpha2-Visual-C++10-2010-32-bits/TGUI-0.6-alpha2/fonts/DejaVuSans.ttf");

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

// Pass the event to all the widgets (if there would be widgets)
gui.handleEvent(event);
}

window.clear();

// Draw all created widgets
gui.draw();

window.display();
}

return EXIT_SUCCESS;
}
Topic archived. No new replies allowed.