Je souhaite signaler une erreur de saisie dans une application wxGTK en définissant l'arrière-plan d'un champ de texte sur rouge en cas d'erreur et sur blanc en cas d'entrée réussie. Toutefois, lorsque la couleur d'arrière-plan est définie via SetBackgroundColor
, la couleur d'arrière-plan d'une sélection inactive est définie sur la couleur . Cela conduit à une situation très indésirable lorsque vous définissez la couleur d'arrière-plan sur blanc: la couleur d'avant-plan du texte sélectionné étant blanche et la couleur d'arrière-plan du texte sélectionné étant également blanche, le texte est illisible.Comment changer la couleur de fond d'un wxTextCtrl sans casser la couleur de sélection inactive?
Comment réinitialiser les couleurs d'un wxTextCtrl afin que le texte sélectionné inactif ait un arrière-plan gris (paramètre par défaut avant SetBackgroundColour)? SetBackgroundStyle(wxBG_STYLE_SYSTEM)
était ma première estimation, mais n'a aucun effet sur wxGTK.
:
#include <wx/textctrl.h>
#include <wx/frame.h>
#include <wx/defs.h>
#include <wx/app.h>
class App : public wxApp {
bool OnInit() {
wxFrame* frame = new wxFrame(NULL, wxID_ANY, wxT("Frame"));
wxTextCtrl* text = new wxTextCtrl(frame, wxID_ANY, wxT("foo bar"));
text->SetBackgroundStyle(wxBG_STYLE_COLOUR);
text->SetBackgroundColour(*wxWHITE);
frame->Show();
return true;
}
};
IMPLEMENT_APP(App);