On 08/12/2013 10:40 AM, Micha wrote:
Hi,
to disable the selection of ListItems (of Form.List, qooxdoo 2.1.1) I use this
code:
list.addListener("changeSelection", function() {
list.resetSelection();
}, this);
Mh, you want to disable the selection after a selection has been made,
right?! Why do you then call .resetSelection(), which resets the
selection to some predefined state, also killing the selection the user
just made?!
This causes a stack overflow when executed.
Yes, naturally. Once a selection has been made, your 'changeSelection'
listener is called. Inside it, you change the selection again, by
calling .resetSelection(). This again triggers the 'changeSelection'
event, which leads to invoking your listener. Which changes the
selection ... ad infinitum.
This does work:
var clrSel = function() {
list.addListenerOnce("changeSelection", function() {
list.resetSelection();
clrSel();
}, this);
clrSel();
Yeah, this breaks the infinite recursion, but only because by the time
the recursive call to clrSel() establishes a new 'changeSelection'
listener, the change event by the call to .resetSelection() has already
passed. This way you handle one change event, then you miss one, the you
handle one, then you miss one, etc.
What is the right way to prevent selecting a list item?
I use the list as a log view, so I want to switch off the item selection.
Ah, ok, so you don't want the user to make any selection at all, right?!
I didn't found a "none" selection mode.
Right, that's probably the problem. Please open an enhancement bug for this.
You could handle it on the ListItem level by calling .setEnabled(false)
when adding each. But this would change the styling to the "disabled"
state and you would need to fix this in the theme to get the old look
back. Probably a bit tedious.
I've looked around and found an old thread that was discussing the same
issue [1]. Your approach with the changeSelection handler can work if
you special-case the resetSelection situation, which has the property of
an empty selection. I've hacked up a short Playground example [2] which
seems to work well enough.
T.
[1] http://qooxdoo.678.n2.nabble.com/Event-stopping-td5095629.html
[2] http://tinyurl.com/looa2j4
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel