Sat 22 Mar 2014 03:09:49 PM UTC, comment #1:
This goes back to at least OF Java package 1.2.8
With octave-3.4.3 & 3.6.4 (both MinGW):
octave:1> [sel, ok] = listdlg ("Liststring", {"One", "Two", "Three"})
...<selecting "Two", clicking OK>
sel =
<Java object: int[]>
ok = 1
octave:2> {"One", "Two", "Three"}(sel(1))
ans =
{
[1,1] = Two
}
octave:3> numel (sel)
ans = 1
octave:4> [sel, ok] = listdlg ("ListString", {"One", "Two", "Three"}, "SelectionMode", "Multiple")
...<selecting "One" and "Three", clicking OK>
sel =
<Java object: int[]>
ok = 1
octave:5> numel (sel)
ans = 2
octave:6> {"One", "Two", "Three"}(sel(1))
ans =
{
[1,1] = One
}
octave:7> {"One", "Two", "Three"}(sel(2))
ans =
{
[1,1] = Three
}
-verbatim-
It isn't straightforward to cast (box) sel into an Octave class:
but as sel can be used for indexing, something along the lines of:
tmp = zeros (numel (sel))
for ii=1:numel (sel)
tmp(ii) = sel(ii);
endfor
gives the desired pointers into ListString.
BTW, the example in listdlg.m isn't at variance with the the bug report and the above observations. Nowhere is it literally stated that sel is an Octave integer. But obviously that is what unwary users would expect.
Another observation:
The actual listing of "One Two Three" doesn't appear on screen unless ListString is in camelcase; IOW the list of choices is empty. Similar holds for other key names.
I'd rather prefer case-insensitive key names. Easily done by morphing the strcmp calls into strcmpi.
Changeset attached for both "issues"
(file #31005)
|