ListBox scrollbar does not move
« on: 16 January 2016, 04:41:49 »
I was looking over the tutorial, and tried to implement the listbox, but the scrollbar does not move when trying to move it. In addition to the ListBox, the combo box drop down feature does not work either. What am I missing?
Thanks in advance.
Here is some code:
Code: [Select]
#include <SFML\Graphics.hpp>
#include <TGUI\TGUI.hpp>
#include <iostream>

using std::cout;
using std::endl;

int main()
{
const unsigned Window_Width = 600;
const unsigned Window_Height = 600;
sf::RenderWindow Window(sf::VideoMode(Window_Width, Window_Height), "TGUI Tutorial Four");

tgui::Gui gui(Window);

if(!gui.setGlobalFont("arial.ttf"))
cout << "Error! Could not load arial.ttf" << endl;

tgui::ListBox::Ptr Listbox(gui);
Listbox->load("C:/TGUI-0.6.1/widgets/Black.conf");
Listbox->setSize(150, 150);
Listbox->setItemHeight(20);
Listbox->setPosition(300.0f, 300.0f);
Listbox->addItem("Item 1");
Listbox->addItem("Item 2");
Listbox->addItem("Item 3");
Listbox->addItem("Item 4");
Listbox->addItem("Item 5");
Listbox->addItem("Item 6");
Listbox->addItem("Item 7");
Listbox->addItem("Item 8");
Listbox->addItem("Item 9");

tgui::ComboBox::Ptr combo_box(gui);
combo_box->load("C:/TGUI-0.6.1/widgets/Black.conf");
combo_box->setSize(120, 21);
combo_box->setPosition(50, 100);
combo_box->addItem("Apple");
combo_box->addItem("Orange");
combo_box->addItem("Grapes");
combo_box->setSelectedItem("Orange");
combo_box->setBackgroundColor(sf::Color::Blue);

while(Window.isOpen())
{
Window.clear();

sf::Event Event;
while(Window.pollEvent(Event))
{
switch(Event.type)
{
case sf::Event::Closed:
Window.close();
break;

case sf::Event::KeyPressed:
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
Window.close();
break;

}

}


gui.draw();

Window.display();
}


return 0;
}

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: ListBox scrollbar does not move
« Reply #1 on: 16 January 2016, 11:30:24 »
You forgot to pass the events to tgui. Inside the pollEvent loop you need to add this line:
gui.handleEvent(Event);

Re: ListBox scrollbar does not move
« Reply #2 on: 17 January 2016, 03:34:28 »
Wow, silly mistake. Thanks for the help.

Good job on the library by the way.