Discussion:
wxListCtrl : How to keep current state when loosing focus
Vincent R.
2014-06-02 07:53:42 UTC
Permalink
Hi,

I am using a wxSortableListCtrl in report mode and single selection
(wxLC_REPORT|wxLC_HRULES|wxLC_VRULES|wxLC_SINGLE_SEL)
and I wanted to know if it would be possible to prevent to loose the
selected state and selected hilited color when we click outside the control
(or even inside the control on the blank space below items) ?



Thanks
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
John
2014-06-03 07:28:43 UTC
Permalink
Post by Vincent R.
Hi,
I am using a wxSortableListCtrl in report mode and single selection
(wxLC_REPORT|wxLC_HRULES|wxLC_VRULES|wxLC_SINGLE_SEL)
and I wanted to know if it would be possible to prevent to loose the
selected state and selected hilited color when we click outside the
control (or even inside the control on the blank space below items) ?
Thanks
From memory a veto to the deselect event will not work. To pre-empt
clicks in the empty area of the listctrl you could bind to
wxEVT_LEFT_DOWN via wxMouseEvent, cast the event object to your ListCtrl
and do something like the following:

long i = lv->GetFirstSelected();
if( lv->HitTest( event.GetPosition(), wxLIST_HITTEST_ONITEM) == i )
event.Skip()
else
// do stuff with i

Clicks outside the ListCtrl shouldn't cause the selection to change but
you will lose the highlight colour that accompanies focus and removed on
loss of focus.

I expect users will find it confusing if the listctrl appeared to have
focus when it doesn't have focus. I guess you could change the
background colour of the selected row in a focus handler to match the
focus colour or to increase the selected no focus colour intensity but
it seems non-compliant with OS platform standards and perhaps a bmp
check or tick might be more appropriate.

John
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
David Connet
2014-06-03 13:35:27 UTC
Permalink
Post by Vincent R.
Hi,
I am using a wxSortableListCtrl in report mode and single selection
(wxLC_REPORT|wxLC_HRULES|wxLC_VRULES|wxLC_SINGLE_SEL)
and I wanted to know if it would be possible to prevent to loose the
selected state and selected hilited color when we click outside the
control (or even inside the control on the blank space below items) ?
Thanks
Could it be that your no-focus-selection color is just very light? The
listctrl does set LVS_SHOWSELALWAYS (on windows, msw/listctrl.cpp). I
have noticed that that color can be very difficult to see on Win7. (I
keep meaning to find which syscolor that is and tweak it a little
darker, but I never get around to it...)

Dave
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Loading...