Main Menu
Menu

Show posts

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 Menu

Messages - Blaxxun

#1
Ah, okay,

i totally missed the fact that "Public Attrbutes inherited from" can actually be unfolded.  ::)

Thank you for this info and the new namespace alternative info.
I think, knowing this its okay without any further overview. :)

Thanks a lot! Its a great GUI!
#2
Hello texus,

thank you for the swift reply!!  :)

I knew that it inherits but wasnt able to find the available keywords/signal words.
Is there an overall info doc somewhere? I couldnt find anything.

Thanks!
#3
Help requests / tgui::EditBox signal on Unfocused
19 November 2019, 19:57:37
Hello forum,

I have an EditBox to enter color values from 0 to 255.

I need to check for correct value entry by the user which i can do with "ReturnKeyPressed".
But if the user just clicks outside the Box and it looses focus i dont have a signal.

Can this be done somehow?

"TextChanged" is not really helpful in my case.

Thanks!
#4
Okay, thank you for your explainations! Its much appreciated! :)

I watched this video about lambdas https://www.youtube.com/watch?v=mWgmBBz0y8c.
I also moved back my variables and edited the lambda captures [].
Now everything still works fine but without making my variables global.

I will look into shared pointers now.

Thank you texus for your help and also for this cool GUI ! :)

#5
Yeah, iam still a noob.  :o  :-[

I know what scopes, references and pointers are but dont really fully understand them yet.
I use references in function headers to avoid copies, but in combination with a foreign library i fail.
I dont know what lamdas are, so i will learn about them now.

I'll try to move the variables back to the main function and try to change the content "in place" and avoiding copies.
I know its wrong what i did. (Although i dont know why. I just read that its wrong to have global variables)

Thanks for the tip with the radio buttons. I do not need any text on top of the buttons. Just an icon image and maybe a tooltip.
#6
I actually want to simulate some Tool buttons.
When you choose a tool then the button stays pressed.
When u choose another tool then this button stays pressed and the previous goes back to unpressed.
I dont know if BitmapButton is the right choice here.

Maybe you have a better oversight of possible features i can use?
Is there a better choice when every button should have a little tool icon?
#7
Okay, i changed it now to BBTN_Erase->connect("pressed", [=]() { do something }); and it works.
First several variables i had in there went red. I had them right after int main(void){}.
Now i put those variables in the header main.h and it seems to work now.

I also had a slider that used [&] first and always worked before (Hue was already in the header).
Now i changed it to slider->connect("ValueChanged", [=]() { Hue = slider->getValue(); }); and it works again.

Thank you very much!  :)
#8
I understand.
i did this now to create the button (minimal code):

auto BBTN_Erase = tgui::BitmapButton::create();
BBTN_Erase->setImage("img/BTN_Eraser.png");
BBTN_Erase->connect("pressed", [&]()
{
if (EraserON) {
EraserON = false;
BBTN_Erase->setImage("img/BTN_Eraser.png");}
else {
EraserON = true;
BBTN_Erase->setImage("img/BTN_EraserON.png");}  <---------- Exception thrown here when i hit keyboard
});
gui.add(BBTN_Erase,"BBTN_Erase");



if (event.key.code == sf::Keyboard::E)
{
if (EraserON) {
EraserON = false;
tgui::BitmapButton::Ptr BBTN_Erase = gui.get<tgui::BitmapButton>("BBTN_Erase");
BBTN_Erase->setImage("img/BTN_Eraser.png");
}
else {
EraserON = true;
tgui::BitmapButton::Ptr BBTN_Erase = gui.get<tgui::BitmapButton>("BBTN_Erase");
BBTN_Erase->setImage("img/BTN_EraserON.png");
}


Compiles fine but i get an exeption in the button creation part! When i hit my shortcut "E" on my keyboard.
#9
Hello, thankls for your answer!

First i created the BBTN_Erase BitmapButton right after int main(void)
{
with
auto BBTN_Erase = tgui::BitmapButton::create();

and i tryd to change/set the Image in the event part of the code with  if (event.key.code == sf::Keyboard::E) BBTN_Erase->setImage("img/BTN_Eraser.png");
But the BBTN_Erase was unknown in this scope.


So i changed the code to the code that i posted in my first post.

I add the BitmapButton with gui.add(BBTN_Erase); like in my first post, when u scroll down the code section u see it.

So i guess that, the error i made, is to believe that the pointer name is the widget name...

I will check... thanks!
#10
Hello forum,

I have a BitmapButton and a keyboard shortcut. (I want to create a toggle button)
Just using the button with the mouse works fine.
Using a keyboard shortcut i cant access the BitmapButton properly (crash).
My goal is to toggle the image of the button everytime when the shortcut is pressed.

This minimal code works fine:

tgui::BitmapButton::Ptr BBTN_Erase = tgui::BitmapButton::create();

BBTN_Erase->setImage("img/BTN_Eraser.png");
BBTN_Erase->setImageScaling(0);
BBTN_Erase->connect("pressed", [&]()
{
if (EraserON)
{
EraserON = false;
BBTN_Erase->setImage("img/BTN_Eraser.png");
}
else
{
EraserON = true;
BBTN_Erase->setImage("img/BTN_EraserON.png");
}
});
gui.add(BBTN_Erase);



And this code throws an exeption:
if (event.key.code == sf::Keyboard::E)
{
if (EraserON)
{
EraserON = false;
tgui::BitmapButton::Ptr BBTN_Erase = gui.get<tgui::BitmapButton>("BTTN_Erase");
BBTN_Erase->setImage("img/BTN_Eraser.png");
}
else
{
EraserON = true;
tgui::BitmapButton::Ptr BBTN_Erase = gui.get<tgui::BitmapButton>("BTTN_Erase");
BBTN_Erase->setImage("img/BTN_EraserON.png");
}
}


What am i doing wrong?

Thanks!!  :)