Got it, thank you! I will implement it like this for now and will wait until you add this future.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuote from: texus on 22 May 2020, 16:12:03
but you could just replace the text with an actual Label widget for now.
class MyTguiSlider : public Panel
{
public:
typedef std::shared_ptr<MyTguiSlider> Ptr;
typedef std::shared_ptr<const MyTguiSlider> ConstPtr;
MyTguiSlider(const sf::String& name, const Layout width = { "100%"});
~MyTguiSlider() {};
static MyTguiSlider::Ptr create(const sf::String& name, const Layout width = { "100%" });
protected:
private:
Label::Ptr m_nameLabel;
Label::Ptr m_valueLabel;
Slider::Ptr m_slider;
};
tgui::MyTguiSlider::MyTguiSlider(const sf::String& name, const Layout width)
{
m_valueLabel = Label::create("100.00");
m_slider = Slider::create();
m_nameLabel = Label::create(name);
getRenderer()->setBackgroundColor({ 100, 100, 60 });
m_slider->setSize("95%", 10);
m_slider->setPosition("&.w/2 - w/2", "nameLabel.bottom + h");
add(m_slider, "slider");
m_valueLabel->setHorizontalAlignment(Label::HorizontalAlignment::Right);
m_valueLabel->setPosition("slider.right - width", "slider.top - height");
add(m_valueLabel, "valueLabel");
m_nameLabel->setMaximumTextWidth(m_slider->getSize().x - m_valueLabel->getSize().x - 10);
m_nameLabel->setPosition("slider.left", 0);
add(m_nameLabel, "nameLabel");
setSize(width, "slider.bottom + 10");
}
Quote from: texus on 24 May 2019, 11:34:06how can I do that?
So basically call gui.handleEvent for every event except for the space key press event.
if(event.type == Event::KeyPressed && event.key.code == Keyboard::Space)
{
handleSpaceKeyEvent();
return;
}
gui.handleEvent();
/* handle other events */
auto button = tgui::Button::create();
button->setRenderer(theme.getRenderer("Button"));
button->connect("pressed", [](){std::cout<<"button pressed" << endl;});
gui->add(button);
/* --- */
sf::Event event;
while (window->isOpen())
{
while (window->pollEvent(event))
{
/* --- */
gui.handleEvent(event);
if (event->type == Event::KeyPressed)
switch (event->key.code)
{
case Keyboard::Space:
cout<< "space key pressed"<<endl;
break;
/* --- */
}
/* --- */
}
}