Opened 7 years ago

Last modified 7 years ago

#14977 new defect

Auto-completion list selection in wxStyledTextCtrl unreadable on Ubuntu

Reported by: Alpha Owned by:
Priority: normal Milestone:
Component: wxStyledText Version:
Keywords: Cc:
Blocked By: Blocking:
Patch: no

Description

On Ubuntu (wxGTK) with default themes, the combination of colors for the selected text (white), and selected text background (light gray) of the auto completion list from wxSTC ( wxStyledText::AutoCompShow() ) make it very difficult to read. The cause appears to be from a focus hack:

        // NOTE: We need to fool the wxListView into thinking that it has the
        // focus so it will use the normal selection colour and will look
        // "right" to the user.  But since the wxPopupWindow or its children
        // can't receive focus then we have to pull a fast one and temporarily
        // parent the listctrl on the STC window and then call SetFocus and
        // then reparent it back to the popup.
        lv->SetFocus();
        lv->Reparent(this);

If lv->SetFocus() is removed, then colors become selected text: black, and selected text background: light gray. Readable, but not desired.

The expected colors (when using the default Ubuntu theme) are selected text: white, and selected text background: orange.

For other discussion and screenshot, see here.

Change History (2)

comment:1 follow-up: Changed 7 years ago by vadz

  • Summary changed from Auto-comp list selection unreadable on Ubuntu to Auto-completion list selection in wxStyledTextCtrl unreadable on Ubuntu

This code (for the reference, it's in source:wxWidgets/trunk/src/stc/PlatWX.cpp) does look quite suspicious to me but I have absolutely no knowledge of it and, in fact, I don't even know what do I need to do to see this popup in the sample so I can't even test it right now. But IMHO the list control should be created with the popup itself as parent and the colours problem should be dealt with in some other way...

comment:2 in reply to: ↑ 1 Changed 7 years ago by Alpha

Replying to vadz:

[...] I don't even know what do I need to do to see this popup in the sample so I can't even test it right now.

The sample unfortunately does not currently demonstrate this feature. Passing the editor to a function such as:

void ShowAutoCompSample(wxStyledTextCtrl* stc)
{
    stc->AutoCompShow(0, wxT("autoComp sample"));
}

on a keyboard shortcut/menu entry should be sufficient. You could also take a look at how Code::Blocks uses it in the function CodeCompletion::CodeCompletePreprocessor() or CodeCompletion::CodeComplete() of file plugins/codecompletion/codecompletion.cpp for real world implementations.

Replying to vadz:

But IMHO the list control should be created with the popup itself as parent and the colours problem should be dealt with in some other way...

That was my first thought, but there does not currently seem to be API exposed in wxListView for setting the colors used during selection.

Note: See TracTickets for help on using tickets.