I made an application which adds check buttons for each entry found in a directory (this part isn't super important). I've noticed that the text on the check buttons don't match what I get when I cout the string.
This is what it is supposed to say v
Also, I've noticed that when I get the utf8 string (.u8string()) of a filesystem path, then scroll away and scroll back, the text changes to garbage. The garbage changes every time I restart my program.
This does not happen when I get a regular string (.string())
The scroll bar also does not show up until I start scrolling (as seen in the first screenshot)
Code:
for (auto& entry : std::filesystem::directory_iterator(std::filesystem::u8path(path)))
{
addentry(entry.path().filename().u8string());
std::cout << entry.path().filename().u8string() << std::endl;
Fl::wait();
}
void addentry(std::string name)
{
ui->scroll->begin();
Fl_Check_Button* o = new Fl_Check_Button(470, 60 + 15 * numbuttons, 1000, 15, name.c_str());
o->down_box(FL_DOWN_BOX);
o->value(1);
o->user_data((void*)(numbuttons));
o->callback((Fl_Callback*)(callback));
o->when(FL_WHEN_CHANGED);
ui->scroll->end();
numbuttons++;
}
UI is defined as
extern UI* ui = new UI()
UI class:
h file:
// generated by Fast Light User Interface Designer (fluid) version 1.0306
#ifndef fltktest_h
#define fltktest_h
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>
extern void run(Fl_Button*, void*);
#include <FL/Fl_Text_Display.H>
#include <FL/Fl_Check_Button.H>
extern void conversion(Fl_Check_Button*, void*);
#include <FL/Fl_Scroll.H>
class UI {
public:
UI();
Fl_Window *window;
Fl_Text_Display *text_display;
Fl_Scroll *scroll;
void show();
};
#endif
cxx file:
// generated by Fast Light User Interface Designer (fluid) version 1.0306
#include "fltktest.h"
UI::UI() {
{ window = new Fl_Window(659, 349, "FLTK test");
window->user_data((void*)(this));
// removed irrelevant stuff
{ scroll = new Fl_Scroll(445, 40, 190, 260, "Title");
{ // padding
Fl_Check_Button* o = new Fl_Check_Button(470, 45, 150, 15);
o->down_box(FL_DOWN_BOX);
o->labeltype(FL_NO_LABEL);
o->hide();
o->deactivate();
} // Fl_Check_Button* o
scroll->end();
} // Fl_Scroll* scroll
window->end();
} // Fl_Window* window
}
void UI::show() {
window->show();
}
Any help is appreciated :)