Changing list view at runtime?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Changing list view at runtime?

keith
Hi, me again, back for another dose of Dolphin knowledge....
Is it possible to change a view at runtime?
Here's my situation:
  I'm using a ListPresenter to show a simple (single selection) list
to the user. Occassionally, I have the situation where I'm displaying
information in the listbox that I'd like to be multi-selection. Is
there a way to either:
a) tell a Multi-select listview to either enable or disable
multi-select
or b) safely morph the single select Listview into a Multi-select at
runtime.

My other option is to have 2 lists - one multi-select and one single
select, and show/hide the appropriate one as needed -- but I thought
maybe this was too "brutish", and there was a more elegant solution
you all could tell me about...

As usual, thanks for the help!

KeithB


Reply | Threaded
Open this post in threaded view
|

Re: Changing list view at runtime?

Ian Bartholomew-18
Keith,

Before a list selection is changed a #selectionChanging: event is triggered.
If you respond to this event you can set the value of its
SelectionChangingEvent argument to false and prevent the change being made.
You should therefore be able to use a MultipleSelectionListPresenter in your
application but also be able prevent the user making multiple selections at
inappropriate times.

I've just had a play (mail me if you want the test code) and this works as
expected with a MultipleSelectionListBox as the view but there appears to be
a bug when used with a MultipleSelectionListView.

This bug appears to be (from a cursory examination) because MSLV uses most
of the superclass' behaviour and this results in a single selection (the one
under the mouse cursor) being passed to #onSelChanging:  It should really
pass all of the new selection - maybe #selectionFromPoint should be
overridden?.  This looks quite similar to Jason's post a few days ago which
referred to a problem when deleting multiple selections.

Regards
    Ian


Reply | Threaded
Open this post in threaded view
|

Re: Changing list view at runtime?

keith
Hi Ian,
As usual, thanks for the excellent help. You're a great repository of
information...ever think about writing a book on Dolphin? (Dolphin
Smalltalk: Tips, Tricks & Traps) :-)

I'm still trying to wrap my mind around the differences between
ListBoxes and Listviews. So far, I've been using Listviews
exclusively, but being a Dolphin novice, I'm not sure if there's a
compelling reason for using one over the other.... any thoughts?

KeithB

"Ian Bartholomew" <[hidden email]> wrote in message news:<insv9.218$XN5.29381@wards>...

> Keith,
>
> Before a list selection is changed a #selectionChanging: event is triggered.
> If you respond to this event you can set the value of its
> SelectionChangingEvent argument to false and prevent the change being made.
> You should therefore be able to use a MultipleSelectionListPresenter in your
> application but also be able prevent the user making multiple selections at
> inappropriate times.
>
> I've just had a play (mail me if you want the test code) and this works as
> expected with a MultipleSelectionListBox as the view but there appears to be
> a bug when used with a MultipleSelectionListView.
>
> This bug appears to be (from a cursory examination) because MSLV uses most
> of the superclass' behaviour and this results in a single selection (the one
> under the mouse cursor) being passed to #onSelChanging:  It should really
> pass all of the new selection - maybe #selectionFromPoint should be
> overridden?.  This looks quite similar to Jason's post a few days ago which
> referred to a problem when deleting multiple selections.
>
> Regards
>     Ian


Reply | Threaded
Open this post in threaded view
|

Re: Changing list view at runtime?

Ian Bartholomew-18
Keith,

> As usual, thanks for the excellent help. You're a great repository of
> information...ever think about writing a book on Dolphin? (Dolphin
> Smalltalk: Tips, Tricks & Traps) :-)

No chance :-)  I can't even get around to (i.e find the enthusiasm for)
writing the documentation for my goodies.  I *hate* writing documentation,
of any sort.

> I'm still trying to wrap my mind around the differences between
> ListBoxes and Listviews. So far, I've been using Listviews
> exclusively, but being a Dolphin novice, I'm not sure if there's a
> compelling reason for using one over the other.... any thoughts?

Off the top of my head...

ListBox is an original Windows widget, ListView is a newer common control.
Because of this ListView has a *lot* of extras
    - Icons
    - Unlimited size (IIRC ListBox is limited to 32768 entries)
    - Virtual.  ListBox needs all the items in the list to be available (for
scrolling for example).  ListView only asks for the items that are actually
being displayed.
    - Multiple columns.
    - Sorting
    - Other stuff :-)

If you want any of the above then you have to use a ListView.  However if
you just want to display a smallish number of objects (or use
#onSelectionChanging in a MultipleSelectionListPresenter :-)) then a ListBox
is probably easiest.

The overview sections in the MSDN library are a good way of finding out what
the various Windows widgets can do.

Regards
    Ian