Main Menu

Recent posts

#71
Help requests / Re: Weird error after updating...
Last post by johnnywz00 - 14 November 2024, 21:56:11
The only message I see is "bad access". And this program worked until I moved the project to a new computer and upgraded to 1.6.1.
There is a Gui object.
There is no error trying to create other kinds of widgets, just EditBox.

ARM Silicon Mac running Sequoia
#72
Help requests / Re: Weird error after updating...
Last post by texus - 14 November 2024, 15:50:32
I'm assuming the message in the thrown error is about no backend existing?

You must first create a Gui object and attach a window to it before you are allowed to create any widgets. Otherwise the widgets can't create textures or texts.
#73
Help requests / Weird error after updating to ...
Last post by johnnywz00 - 14 November 2024, 15:12:07
Some time ago I wrote some SFML projects using TGUI 0.6, mainly to implement a high scores window. Now I've moved my work to a new computer and upgraded to 1.6.1. The first project seemed to go fine. The second project is almost copy-paste of the first in terms of the code that uses TGUI, to implement high scores.
I am getting a bad access error with the simple line
```
auto eb = tgui::EditBox::create();
```
What is most odd to me is if I cut that line and paste it as the very first line in `main()`, it still throws the error. And yet `tgui::Panel::create()` (and probably most others) do not throw the error. Any explanations?

The stack trace seemed to indicate it was on Backend::createText

Thanks!
#74
General Discussion / Re: multiple windows
Last post by texus - 06 November 2024, 19:49:58
In the latest TGUI version, gui.handleEvent will now return false when the event is for a different window.
I didn't put it behind an option, the filter is always enabled.
#75
General Discussion / Re: multiple windows
Last post by texus - 06 November 2024, 18:37:21
Apparently SDL3 added a SDL_GetWindowFromEvent(event) function that you can use to determine which window the event came from (and thus you can use that to forward the event to the right gui, or forward it to both guis when the function returns NULL).
#76
General Discussion / Re: Custom Widgets - Clock and...
Last post by texus - 06 November 2024, 18:32:10
No. If you want something like that then I'm afraid you will have to create it yourself.
#77
General Discussion / Re: Custom Widgets - Clock and...
Last post by KSergeyP - 06 November 2024, 16:23:41
Is it tgui?
#78
General Discussion / Re: multiple windows
Last post by texus - 06 November 2024, 14:37:58
Quote from: KSergeyP on 06 November 2024, 14:00:53But it would be better to implement this in TGUI
Since TGUI already has to handle each type of event separately, it should indeed be possible to do the filtering inside "gui.handleEvent".

The only issue with it, is that it would become harder to add fake events (e.g. create your own mouse move event and passing that to the gui). So I'll add the filtering to TGUI, but I might put it behind some option that you need to enable first to keep the filtering on windowID disabled by default.
#79
General Discussion / Re: multiple windows
Last post by KSergeyP - 06 November 2024, 14:00:53
Thanks, it's clearer now.
It looks like you need to write a wrapper to determine which window the event is from, analyzing all events that have a WindowID.
But it would be better to implement this in TGUI
#80
General Discussion / Re: multiple windows
Last post by texus - 06 November 2024, 13:23:20
The closest thing that I have is an older example that I once wrote: https://tgui.eu/tutorials/0.9/sdl-backend/#multiple-windows (it's for TGUI 0.9 which is why it e.g. uses GuiSDL instead of just Gui)

You basically need the correct OpenGL context selected whenever interacting with the gui (with SDL_GL_MakeCurrent in SDL2), and you need to use the windowID in the events to figure out which gui they belong to.

I just noticed that the example code actually contains a mistake. It accesses event.window.windowID but that is only allowed for window events (e.g. windows resize). Other events (e.g. SDL_KeyboardEvent) also contain a windowID property though.

I don't recommend using different threads for this though. TGUI code can only be accessed from one thread at a time (so you can't be handling events or drawing on both threads at the same time). You would need locks everywhere. Also OpenGL isn't really thread-safe. You need to activate the correct OpenGL context (with SDL_GL_MakeCurrent) before rendering, so you can't render with both threads at the same time even if TGUI was thread-safe.