My problem is that my users must choose one of a number of machine states which have short identifiers, not particularly meaningful for them.
However, for each state there are a number of tests to be performed, and for these there are more meaningful descriptions available.
I don't have influence on the identifiers, so I need to present the users with the test descriptions, but they are too long to put them all on one line for a given state.
wxSingleChoiceDialog would be exactly what I need, but it is based upon wxListBox, which doesn't support multi-line items.
Before I do some nasty cut-and-pasting of the source, has anyone done this already or got a better idea?
P.S. I also thought of using a wxTree control instead with the state identifiers at the top level and the test descriptions as branches, but this could confuse the users to think that they are selecting a single test rather than the whole set for the state.
Need wxSingleChoiceDialog using wxHtmlListBox?
Need wxSingleChoiceDialog using wxHtmlListBox?
wxWidgets 3.1.0
Boost 1.65
VS 2017
Win 7
Boost 1.65
VS 2017
Win 7
Re: Need wxSingleChoiceDialog using wxHtmlListBox?
I'd probably put the "more meaningful description" as both a tooltip on mouse over and as a separate text field placed somewhere reasonable on the GUI upon selection of a test.
Re: Need wxSingleChoiceDialog using wxHtmlListBox?
Thank you coderrc - that's probably the best way to do it.
The tooltip would be a little tricky (to know which item in the ListBox the mouse pointer is over), but I can omit that when I display the description for the selected item prominently (left the list, right the description of the current selection).
Actually a standard pattern, but my thought processes were stuck in a dead-end and I only broke out with your help!
The tooltip would be a little tricky (to know which item in the ListBox the mouse pointer is over), but I can omit that when I display the description for the selected item prominently (left the list, right the description of the current selection).
Actually a standard pattern, but my thought processes were stuck in a dead-end and I only broke out with your help!
wxWidgets 3.1.0
Boost 1.65
VS 2017
Win 7
Boost 1.65
VS 2017
Win 7
- eranon
- Can't get richer than this
- Posts: 867
- Joined: Sun May 13, 2012 11:42 pm
- Location: France
- Contact:
Re: Need wxSingleChoiceDialog using wxHtmlListBox?
You just derive from wxSingleChoiceDialog and catch the mouse movements over the inner wxListBox.macsinus wrote:Thank you coderrc - that's probably the best way to do it.
The tooltip would be a little tricky (to know which item in the ListBox the mouse pointer is over) [...]
Tested adding this in the dialogs.h of dialogs sample:
Code: Select all
class MyChoiceDialog : public wxSingleChoiceDialog
{
public:
MyChoiceDialog(wxWindow *parent, const wxString& message, const wxString& caption, int n,
const wxString *choices, void **clientData = NULL, long style = wxCHOICEDLG_STYLE,
const wxPoint& pos = wxDefaultPosition)
: wxSingleChoiceDialog(parent, message, caption, n, choices, clientData, style, pos){
m_listbox->Connect(wxEVT_MOTION, wxMouseEventHandler(MyChoiceDialog::OnMouseOver), NULL, this);}
private:
void OnMouseOver(wxMouseEvent& event){
wxPoint ptCurr = event.GetPosition();
wxListBox* pCtrl = static_cast<wxListBox*>(event.GetEventObject());
long nItem = pCtrl->HitTest(ptCurr);
if (nItem != wxNOT_FOUND){
pCtrl->SetToolTip(wxString::Format("Item %ld, Coord. %i x %ipx", nItem, ptCurr.x, ptCurr.y));}}
};
Here is the result:
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
Re: Need wxSingleChoiceDialog using wxHtmlListBox?
Thank you eranon - that's elegant, I wasn't aware that the item can be identified with the HitTest method.
In my case I'll stick to the 2-pane solution because the user might prefer to work with the keyboard or a touch-screen rather than the mouse, but it's something I'm glad to have learned.
In my case I'll stick to the 2-pane solution because the user might prefer to work with the keyboard or a touch-screen rather than the mouse, but it's something I'm glad to have learned.
wxWidgets 3.1.0
Boost 1.65
VS 2017
Win 7
Boost 1.65
VS 2017
Win 7
- eranon
- Can't get richer than this
- Posts: 867
- Joined: Sun May 13, 2012 11:42 pm
- Location: France
- Contact:
Re: Need wxSingleChoiceDialog using wxHtmlListBox?
Of course, it all depends on your user's habits and contexts... And the two-panels way is maybe more "rich" on screen.
Also, an alternative could be to build your choice dialog in HTML relaying on javascript to return the selection, but it would require to go with wxWebView... An overkill for a single dialog (to keep in mind, in case you already use wxWebView elsewhere in your app).
Also, an alternative could be to build your choice dialog in HTML relaying on javascript to return the selection, but it would require to go with wxWebView... An overkill for a single dialog (to keep in mind, in case you already use wxWebView elsewhere in your app).
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
Re: Need wxSingleChoiceDialog using wxHtmlListBox?
I might use HTML for the right-hand panel...
wxWidgets 3.1.0
Boost 1.65
VS 2017
Win 7
Boost 1.65
VS 2017
Win 7
- eranon
- Can't get richer than this
- Posts: 867
- Joined: Sun May 13, 2012 11:42 pm
- Location: France
- Contact:
Re: Need wxSingleChoiceDialog using wxHtmlListBox?
Yep, but I guess going with wxHtmlWindow (light, self-contained class) rather than wxWebView (relaying on underlying back-end -- Trident or WebKit by default).
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
Re: Need wxSingleChoiceDialog using wxHtmlListBox?
I've attached my solution as a zip file.
Works for me, no guarantees!
The fbp file is a wxFormBuilder project which I used to generate the base window class.
Works for me, no guarantees!
The fbp file is a wxFormBuilder project which I used to generate the base window class.
- Attachments
-
- wxTwoPaneChoiceDialog.zip
- (7.18 KiB) Downloaded 113 times
wxWidgets 3.1.0
Boost 1.65
VS 2017
Win 7
Boost 1.65
VS 2017
Win 7