Comments (8)
As explained on the forum, the default Black style doesn't has focused images.
But after adding the FocusedImage option in the config file, does this code work?
The code below works fine for me, so if it works for you as well then you should write small piece of code to reproduce the problem.
#include <TGUI/TGUI.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(930, 700), "TGUI window");
tgui::Gui gui(window);
if (gui.setGlobalFont("TGUI/fonts/DejaVuSans.ttf") == false)
return 1;
tgui::Button::Ptr button(gui);
button->load("TGUI/widgets/Black.conf");
button->setPosition(40, 25);
button->setText("Quit");
button->setCallbackId(1);
button->bindCallback(tgui::Button::LeftMouseClicked | tgui::Button::SpaceKeyPressed | tgui::Button::ReturnKeyPressed);
button->setSize(300, 40);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
gui.handleEvent(event);
}
tgui::Callback callback;
while (gui.pollCallback(callback))
{
std::cout << "CALLBACK" << std::endl;
}
window.clear();
gui.draw();
window.display();
}
return 0;
}
from tgui.
No, your code doesn't work still. Minimum code required is the same code as yours minus the "leftMouseClicked". leftMouse trigger I get, but the SpaceBar and ReturnKey callbacks do not get propagated. When I do button->bindCallback(tgui::Button::AllButtonCallbacks in your example code I do not catch anything from the keys, only mouse movement, focussing/unfocussing and the like. I use development screenshot from the day before yesterday which I compiled with gcc.
from tgui.
Please try your code snippet again with
button->bindCallback(tgui::Button::LeftMouseClicked | tgui::Button::SpaceKeyPressed | tgui::Button::ReturnKeyPressed);
replaced by
button->bindCallback(tgui::Button::SpaceKeyPressed | tgui::Button::ReturnKeyPressed);
from tgui.
"No, your code doesn't work still. Minimum code required..."
I am sorry this may have been misleading, Your code of course works because it contains the leftMouseClicked callback. But the other callbacks don't. See my comment above. Also it has nothing to do with our focusedImage discussion on the forums.
from tgui.
I meant that space and return key callbacks worked for me, so after changing that line it still works.
The important question is: do you see the focused image when you click on the button (or press tab)?
Because this has everything to do with the FocusedImage on my side.
With an unchanged Black.conf, there is no focus image, the button can't be focused, and the space and return key callback will never work because the button is never focused.
When adding the three lines below in the Button section in Black.conf, the focus image shows up, the button gets focused when clicked (or when pressing tab), and the space and return key callbacks work when the button is focused.
FocusedImage_L = "Black.png" ( 0, 175, 50, 50)
FocusedImage_M = "Black.png" ( 50, 175, 100, 50)
FocusedImage_R = "Black.png" (150, 175, 50, 50)
If you do see the focused image and the callbacks still don't work, then I simply cannot reproduce the issue and then I will have to do some other tests for which I have no time now (I have an exam in a few days).
from tgui.
Ok, I am very embarrassed. Actually, your minimum example does work.
The problem only arises when the button(s) are in a grid, for some reason they displayed their focused images and but reacted to mouse callbacks only. Turned out one has to focus() the grid before so KeyPressed actually gets propagated to the childWidgets. Somehow it is not enough to only focus() the button. LeftClick always worked because I speculate, that then the grid would be focussed() by it anyway.
I hope your exam turns out well.
from tgui.
http://forum.tgui.eu/index.php/topic,124.0.html
The grid needs to be focused.
Edit: I originally had the wrong link in there, sorry!
from tgui.
Ok, now at least I know what the problem is.
It shouldn't be too hard to fix, but I should first test the impact of the changes when having multiple child windows and when tabbing between widgets etc.
from tgui.
Related Issues (20)
- Autocomplete support for EditBox HOT 2
- Can not input CJK words HOT 9
- Black background shown when changing window size HOT 4
- How to customize the window's title bar and frame HOT 2
- How to implement a polygon window HOT 2
- Hover style does not disappear when mouse moves out of the window HOT 6
- Add a 2d chart or rendering 3d data for TGUI? HOT 1
- Chinese support? HOT 5
- Focus Issues HOT 1
- [ANNOUNCE] The TGUI now distributed via MSYS2 on Windows HOT 1
- CMake fails to install pkg-config files HOT 2
- On macOS, Input Method Editors(IME) behavior seems incorrect. HOT 6
- How to use SDL2/3 backend with cmake `FetchContent` HOT 2
- [Question] How to compile my first example of TGUI ? HOT 13
- [Bug] Dead radio button text HOT 3
- [Bug] Tabs state after disabled tab click HOT 2
- FileDialog documentation needs clarification and maybe working examples HOT 4
- Is there a C binding? HOT 12
- Raylib backend? HOT 15
- Cannot delete widgets inside of the gui-builder HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tgui.